问题
Just was checking this episode by Ryan Bates (http://railscasts.com/episodes/52-update-through-checkboxes) and it seems that Rails 3.2.x has different setup.
Thus map.resources :tasks, :collection => { :complete => :put }
does not produce expected result, as it drops an issue that complete_tasks_path
does not exist. Could you please let me know how to customise routing in this particular situation?
Also seems that check_box_tag
requires different attributes other than Ryan puts in there. AS it writes back unexpected kEND...
Any help appreciated
回答1:
It sounds like you want the following which defines a new "completed" action on the collection, accessible at /tasks/completed
.
Here are three ways of adding an additional action on the collection
resources :tasks do
put :completed, :on => :collection
# --- OR ---
collection do
put :completed
# additional collection action here ...
end
# --- OR ---
collection { put :completed }
end
This will define a completed_tasks_path
method, and route to the completed
action of your TasksController
.
来源:https://stackoverflow.com/questions/12583987/routing-and-checkboxes-update-from-rails-1-x-x-to-3-2-8