0

I tried following the advice in this Rails3 Routes - Passing parameter to a member route

I have: _health.html (partial)

<%= 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

When I do this I get this error: ActionView::Template::Error (undefined method `flag_contact_flags_path' for #<#:0x00000101430358>):

When I rake routes I show: GET /contact_flags/flag/:id(.:format) {:action=>"flag", :controller=>"contact_flags"}

Why doesn't think work?

I really need to pass the :id parameter.. any ideas?

Thanks

Community
  • 1
  • 1
looloobs
  • 761
  • 2
  • 11
  • 24

1 Answers1

0

Looks like you need to change up the route you're pointing to. Try contact_flags_path(@id) instead of flags_contact_flags(@id).

Any luck?

rennekon
  • 157
  • 2
  • 7
  • Thanks, but no luck there.. if I do that it takes out my flag action all together. Then I get something like this "/contact_flags.057da91cb36d438540f74bfed0764af16d86efe5" The id is correct, but now the action is not right, and even with the original route that it puts a period instead of a slash... just not sure why? – looloobs Jul 25 '11 at 15:28
  • Ah sorry, my office is still working in Rails2 so I'm not up to date on all the new routing stuff they've got in Rails3. I'd recommend checking the online routing documentation and seeing if it can help at all. – rennekon Jul 25 '11 at 16:10