I’m trying to create a restful route for a custom action and I can not
seem to get it right.
This is the code in my routes.rb
map.resources :leagues
map.resources :leagues, :collection => {:old => :get}
old is an action in my leagues controller that will retrieve and
display a list of older leagues (like index but just a different set
of data).
I’m using this generated helper method:
<%= link_to ‘List older league postings’, old_leagues_url %> I also
tried old_leagues_path
and it seems to generate the url I would expect.
http://localhost:3000/leagues/old
But when I click on the link I get this error:
Couldn’t find League with ID=old
For some reason it’s trying to ‘show’ the league old.
I used rake routes and it shows what I would expect to be the correct
route:
old_leagues GET /leagues/old
{:controller=>“leagues”, :action=>“old”}
formatted_old_leagues GET /leagues/old.:format
{:controller=>“leagues”, :action=>“old”}
Can somebody help me out, I’m really stuck on this…
Thanks