我有以下途径:没有路由与成员资源相匹配的Rails
resources :sources do
member do
get 'parse'
end
end
而下面的控制器:
class SourcesController < ApplicationController
before_filter :authenticate_admin!
def index
@sources = Source.all
end
def parse
end
end
我有,我想触发解析动作的形式控制器。我不喜欢这样写道:
<% @sources.each do |source| %>
<tr>
<td><%= source.name %></td>
<td><%= source.url %></td>
<td>
<%= form_for source, url: {action: 'parse'} do |f| %>
<%= f.submit "Parse this source" %>
<% end %>
</td>
</tr>
<% end %>
而且我不断收到:
Failure/Error: visit "/sources"
ActionView::Template::Error:
No route matches {:action=>"parse", :controller=>"sources"}
而且,在我耙路线,我可以看到这一点:
parse_source GET /来源/:ID /解析(。:format)sources#parse
这是为什么?我的行为没有定义?
感谢您的快速回复。我得到这个如果这样做:''未定义的方法'model_name'符号:类'' –
有趣。为什么我不能做form_for [source,:parse] - 做'url:{action:'parse',id:source.id},方法:: get''的作品... –
对不起,我有那倒退。它是'[:parse,source]'。 – meagar