我有以下路由:
resources :pages do
resources :logos do
member do
post 'vote'
end
end
end
然后我有一个在/ pages /:page_id / logos中呈现的视图,如下所示:
<ul>
<% @logos.each do |logo| %>
<li>
<%= image_tag(logo.url) %>
<%= form_for([logo.page, logo], url: {action: "vote"}, :method => :post) do |f| %>
<% end %>
</li>
<% end %>
</ul>
我一直收到这个错误:
No route matches {:action=>"vote", :page_id=>"95", :controller=>"logos"}
我在这里缺少什么?
答案 0 :(得分:0)
尝试
form_for [logos.page, logo, :vote], method: :post
或者,可能是动作在数组中首先出现
[:vote, logo.page, logo]
请原谅,我不必再查一查了。