问题描述
刚刚正在查看Ryan Bates(http://railscasts.com/episodes/52-update-through-checkboxes)的这一集,看来Rails 3.2.x具有不同的设置。
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.
因此 map.resources:tasks,:collection => {:complete => :put}
不会产生预期的结果,因为它丢弃了 complete_tasks_path
不存在的问题。您能否让我知道如何在这种特殊情况下自定义路由?
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?
还似乎 check_box_tag
需要不同的属性除了瑞安放在那里。如它回写意外的kEND ...
Also seems that check_box_tag
requires different attributes other than Ryan puts in there. AS it writes back unexpected kEND...
任何帮助表示赞赏
推荐答案
听起来像是您想要以下内容在集合上定义一个新的完成操作,可通过 / tasks / completed $ c访问$ c>。
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
这将定义 completed_tasks_path
方法,并路由到 completed $
TasksController
的c $ c>操作。
This will define a completed_tasks_path
method, and route to the completed
action of your TasksController
.
这篇关于路由和复选框从Rails 1.x.x更新到3.2.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!