I am new to rails and try to achieve a simple task. I want to switch the boolean attribute "done" to the image click. In my opinion, my link looks like this:
<%= link_to image_tag("done.png"),
feed_item,
:controller => :calendars, :action=>:toggle_done,:id=> feed_item.id,
:title => "Mark as done", :remote=> true, :class=>"delete-icon" %>
I added the route as follows:
resources :calendars do
get 'toggle_done', :on => :member
end
in the controller, I created a method:
def toggle_done
@calendar = Calendar.find(params[:id])
toggle = !@calendar.done
@calendar.update_attributes(:done => toggle)
respond_to do |format|
flash[:success] = "Calendar updated"
format.html { redirect_to root_path }
format.js
end
When I click on the image, nothing happens, I see the following error:
Started GET "/toggle_done" for 127.0.0.1 at 2010-12-27 13:56:38 +0530
ActionController::RoutingError (No route matches "/toggle_done"):
I am sure that there is something very trivial that I am missing here.
source
share