我有一個表單來更新模型的屬性 - 我不希望它轉到標準更新操作,我希望它轉到不同的操作。在form_for action中傳遞id
<% for car in @cars %>
<%= form_for car, :url => { :action => "custom_action/#{car.id}" } do |f| -%>
這是給下面的錯誤 -
No route matches {:action=>"custom_action/1", :controller=>"cars"}
但是,如果我訪問的URL - custom_action/1 - 我沒有得到路由錯誤。
任何想法,爲什麼我不能這樣做?
非常感謝 - 現在查看路線。 – Finnnn 2012-01-03 15:24:49
在你的路線中,你會想要一些像資源:汽車; post:custom_action,:on =>:member;那麼你可以在你的控制器和視圖中使用'custom_action_cars_path(car)'。 – 2012-01-03 15:31:58