# REST and extra actions

**URL:** <https://www.ruby-forum.com/t/rest-and-extra-actions/144264>\
**Category:** Rails\
**Created:** [July 27, 2008, 10:24pm UTC](https://www.ruby-forum.com/t/rest-and-extra-actions/144264 "2008-07-27T22:24:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DS\_Mick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9f8e36/32.png) [@DS\_Mick](https://www.ruby-forum.com/u/DS_Mick)\
**Post date:** [July 27, 2008, 10:24pm UTC](https://www.ruby-forum.com/t/rest-and-extra-actions/144264/1 "2008-07-27T22:24:01Z")

</div>

Hi,

I’m trying to implement some charts in my REST application. But I  
can’t seem to use an extra action like “chart” in my controller.  
Becouse of the rest approach, it sees the action name as an id.

Does anyone know how to overcome this? So that I can visit the charts  
page of a sertain resource like /resource/charts ?

I know I could create a new controller and not adding it to the  
resources in the routes file, but I would like to have the carts in  
the resource controller, becouse in my opinion, the carts view belongs  
to the resource.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![DS\_Mick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9f8e36/32.png) [@DS\_Mick](https://www.ruby-forum.com/u/DS_Mick)\
**Post date:** [July 28, 2008, 4:15am UTC](https://www.ruby-forum.com/t/rest-and-extra-actions/144264/2 "2008-07-28T04:15:30Z")

</div>

The first option is to make a completely new controller for charts. The  
index action would list all available charts and the show action lists  
the  
specific chart. That is the most RESTful approach

Another option would be to modify the show action so that it shows the  
chart.

/foo/1.png =\> displays the chart

Finally, if you absolutely must, you can use a :member action

map.resource :foos, :member =\> {:chart =\> :get}

/foos/1/chart

or map.resource :foos, :collection =\> {:charts =\> :get}

/foos/charts

A “collection” is like a list view - dealing with multiple objects  
A “member” is for dealing with a specific object.
