【发布时间】:2011-06-14 05:25:33
【问题描述】:
好的,这里出现了一个非常奇怪的路由错误。
No route matches {:controller=>"subscriptions", :action=>"change"}
Extracted source (around line #22):
19: <td><%= s.product.name %></td>
20: <td><%= s.calc_time_to_next_arrival %></td>
21: <td>
22: <%= form_for(:subscription, s, :url => { :action => "change" }, :id => s) do %>
23: <%= label_tag(:q, "Days to delay:") %>
24: <%= text_field_tag(:query) %>
25: <%= check_box_tag(:always) %>
然而,如果我运行 rake 路线,这就是我得到的
change_subscription GET /subscriptions/:id/change(.:format {:controller=>"subscriptions", :action=>"change"}
很确定这意味着它应该在那里。不知道发生了什么。
这是在 routes.rb 中声明路线的地方
resources :subscriptions do
member do
get 'change'
end
end
这是订阅的控制器
def change
@subscription = Subscription.find(params[:id])
@subscription.change(:query, :always)
redirect_to :back
end
【问题讨论】:
标签: ruby-on-rails controller routes