【发布时间】:2011-10-12 16:36:46
【问题描述】:
我尝试遵循Rails3 Routes - Passing parameter to a member route中的建议
我有: _health.html(部分)
<%= link_to image_tag("icons/pro_gray.png", :border =>'none'), flag_contact_flags_path(@id), :action => "flag", :id => @id, :remote => true, :class => 'flag' %>
routes.rb
resources :contact_flags do
get 'flag/:id', :action => 'flag', :on => :collection
end
当我这样做时,我得到这个错误: ActionView::Template::Error(# 的未定义方法 `flag_contact_flags_path'):
当我搜索路线时,我会显示: GET /contact_flags/flag/:id(.:format) {:action=>"flag", :controller=>"contact_flags"}
为什么认为不起作用?
我真的需要传递 :id 参数.. 有什么想法吗?
谢谢
【问题讨论】:
标签: ruby-on-rails routing