Restful Route for a custom action

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.

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
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…


On Dec 27, 7:21 pm, Mark [email protected] wrote:

This is the code in my routes.rb
map.resources :leagues
map.resources :leagues, :collection => {:old => :get}

You restarted the server after changing routes.rb, right? No, of
course you did. Never mind.


What version of Rails?

On Dec 28, 2007 3:10 PM, Mark W. [email protected] wrote:


Ryan B.
Feel free to add me to MSN and/or GTalk as this email.

I’m using rails 2.0.2 and yes, I have restarted the server.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs