# Restful Route for a custom action

**URL:** <https://discuss.rubyonrails.org/t/restful-route-for-a-custom-action/22318>\
**Category:** rubyonrails-talk\
**Created:** [December 28, 2007, 3:21am UTC](https://discuss.rubyonrails.org/t/restful-route-for-a-custom-action/22318 "2007-12-28T03:21:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark6](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mark6](https://discuss.rubyonrails.org/u/Mark6)\
**Post date:** [December 28, 2007, 3:21am UTC](https://discuss.rubyonrails.org/t/restful-route-for-a-custom-action/22318/1 "2007-12-28T03:21:35Z")

</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:** ![Mark\_Wilden](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Mark\_Wilden](https://discuss.rubyonrails.org/u/Mark_Wilden)\
**Post date:** [December 28, 2007, 4:40am UTC](https://discuss.rubyonrails.org/t/restful-route-for-a-custom-action/22318/2 "2007-12-28T04:40:25Z")

</div>

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

///ark

---

<div class="post-metadata">

**Author:** ![Mark6](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mark6](https://discuss.rubyonrails.org/u/Mark6)\
**Post date:** [December 28, 2007, 3:49pm UTC](https://discuss.rubyonrails.org/t/restful-route-for-a-custom-action/22318/3 "2007-12-28T15:49:00Z")

</div>

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