我在使用 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>
路线.rb:
resources :businesses do
member do
post 'publish'
end
end
耙路线:
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 的类似问题,但没有找到适合我的问题:(。