I get this error:
Started POST "/admin/reports/2/backfill" for 127.0.0.1 at Thu Dec 29 16:09:00 -0500 2011
ActionController::RoutingError (No route matches "/admin/reports/2/backfill"):
when I post this form:
<%=form_for @report, {:url => report_backfill_path(@report.id), :method => :post} do |f| %>
<%=label_tag(:days, "number of days to backfill")%>
<%=select_tag(:days, options_for_select((1..100).to_a.map{|i| [i,i]}))%>
<%=f.submit "backfill!" %>
<% end %>
but the route is defined, check out the output from my rake routes command:
report_backfill POST /admin/reports/:report_id/backfill(.:format) {:controller=>"reports", :action=>"backfill"}
The page containing this form renders fine, it's just when I post it that I get the error.
Any ideas?
Because you use form_for @report
and @report
is an existing model, it generates the PUT helpers in the hidden fields, which makes the route engine think it is a PUT request.
Actually, to follow the rails conventions, since you are calling an extra method on the existing report (even though the side effect may be to create things), I would change the routing to use :put
instead of :post
, and leave the form alone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.