# Passing Params to Named Restful Routes

**URL:** <https://www.ruby-forum.com/t/passing-params-to-named-restful-routes/122836>\
**Category:** Rails\
**Created:** [December 12, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/passing-params-to-named-restful-routes/122836 "2007-12-12T18:22:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdevore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@gdevore](https://www.ruby-forum.com/u/gdevore)\
**Post date:** [December 12, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/passing-params-to-named-restful-routes/122836/1 "2007-12-12T18:22:25Z")

</div>

I am a bit of newbie and have a question:

Can you pass additional parameters to named restful routes that aren’t  
nested. For example if I have a named route  
classroom\_path(@classroom.id) can I also pass a topic.id or other  
params without having to create nested resources?

---

<div class="post-metadata">

**Author:** ![gdevore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@gdevore](https://www.ruby-forum.com/u/gdevore)\
**Post date:** [January 24, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/passing-params-to-named-restful-routes/122836/2 "2008-01-24T14:59:43Z")

</div>

gdevore wrote:

> I am a bit of newbie and have a question:
> 
> Can you pass additional parameters to named restful routes that aren’t  
> nested. For example if I have a named route  
> classroom\_path(@classroom.id) can I also pass a topic.id or other  
> params without having to create nested resources?

Yes, I think so.  
You have to just do something like:  
classroom\_path(:classroom\_id =\> @classroom.id, :otherparam =\> topic.id)  
Notice that classroom id has to be set also as an entry in the hash,  
cause you cannot mix something like:  
classroom\_path(@classroom.id, :otherparam =\> topic.id)

Then in the controller you receive this, you just have to ask:  
if params[:otherparam]  
…  
to get the topic.
