# Restful Route for a custom action

**URL:** <https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374>\
**Category:** Rails\
**Created:** [December 28, 2007, 4:22am UTC](https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374 "2007-12-28T04:22:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [December 28, 2007, 4:22am UTC](https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374/1 "2007-12-28T04:22:21Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [December 28, 2007, 5:41am UTC](https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374/2 "2007-12-28T05:41:17Z")

</div>

On Dec 27, 7:21 pm, Mark [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

///ark

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [December 28, 2007, 5:54am UTC](https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374/3 "2007-12-28T05:54:09Z")

</div>

What version of Rails?

On Dec 28, 2007 3:10 PM, Mark W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ///ark
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

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

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [December 28, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/restful-route-for-a-custom-action/124374/4 "2007-12-28T16:49:25Z")

</div>

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