Routing and checkboxes update from rails 1.x.x to 3.2.8

烂漫一生 提交于 2019-12-11 19:57:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!