我遇到了Rails的问题,我收到以下错误:
No route matches {:action=>"publish", :controller=>"businesses"}
违规代码:
<div id="searchDatesDiv" style="margin: 0 auto;">
<%= form_tag(publish_business_path, :method => :post) do %>
<%= submit_tag("Publish") %>
<% end %>
</div>
routes.rb中:
resources :businesses do
member do
post 'publish'
end
end
rake routes:
registration GET /registrations/:id(.:format) registrations#show
publish_business POST /businesses/:id/publish(.:format) businesses#publish
businesses GET /businesses(.:format) businesses#index
POST /businesses(.:format) businesses#create
我可以看到rake路线中定义的路径。为什么我收到此错误?表单也是POST方法。任何帮助都会很棒!我曾尝试在SO上查看类似的问题,但没有找到一个适合我的情况:(。
答案 0 :(得分:0)
您的商家发布路径需要您未提供的id参数。将业务对象传递给路径助手:
<%= form_tag(publish_business_path(@business), :method => :post) do %>