# Adding custom routes to a restful app

**URL:** <https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782 "2007-09-17T13:25:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782/1 "2007-09-17T13:25:42Z")

</div>

i’ve done a few project using restful routing but now i need to add an  
action that isn’t part of one of the main crud methods.

i added this to my routes.rb file:

map.resources :works, :collection =\> { :featured =\> :get }

and have a “featured” action in the works controller. but for some  
reason everytime i try to go to [http://localhost:3000/works/featured](http://localhost:3000/works/featured),  
i get an unknown action error. looking at the log file, it’s trying to  
find this page:

Parameters: {“action”=\>“show”, “id”=\>“featured”,  
“controller”=\>“works”}

is there something i did wrong or something i missed in order to make  
this work?

thanks.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [September 25, 2007, 11:03pm UTC](https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782/2 "2007-09-25T23:03:54Z")

</div>

You would have to use the URL:

[http://localhost:3000/works;featured](http://localhost:3000/works;featured)

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [September 25, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782/3 "2007-09-25T23:07:38Z")

</div>

thanks. yeah i was just trying to access the url wrong.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [September 25, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/adding-custom-routes-to-a-restful-app/114782/4 "2007-09-25T23:10:53Z")

</div>

map.feature ‘works/featured’, :controller =\> ‘works’, :action =\>  
‘featured’

then user feature\_url or feature\_path to get at a link to it. I hope  
this gets you where you need to be headed.

Amos

On 9/16/07, Josh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i get an unknown action error. looking at the log file, it’s trying to
> 
> >

## – Amos K. A. King Software Development and Consulting, L.C. [http://dirtyInformation.com](http://dirtyInformation.com)

Looking for something to do? Visit [http://ImThere.com](http://ImThere.com)
