# From Router To Controller

**URL:** <https://www.ruby-forum.com/t/from-router-to-controller/147474>\
**Category:** Rails\
**Created:** [September 2, 2008, 8:57am UTC](https://www.ruby-forum.com/t/from-router-to-controller/147474 "2008-09-02T08:57:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Taylor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c0e974/32.png) [@Gary\_Taylor](https://www.ruby-forum.com/u/Gary_Taylor)\
**Post date:** [September 2, 2008, 8:57am UTC](https://www.ruby-forum.com/t/from-router-to-controller/147474/1 "2008-09-02T08:57:33Z")

</div>

Hi,  
I have an application which I am currently writing that I am  
dividing up into re useable plugins.  
Each plugin needs to know as little as possible about its  
surroundings.

So, for example - I have a forum plugin and a ‘forum’ can belong to  
something - whether that is a ‘User’, a ‘Site’ or anything else - the  
forum knows nothing of these.  
BUT, if I have a URL like this - /sites/1/users/3/forums/2  
I do not want to just look at the forum id number 2 - I want to fetch  
site 1, then find user 3 in its related users, then find forum 2 in  
its related forums. So, if the url is incorrect, you will quite  
rightly get a 404 error or something.

The router passes site\_id and user\_id into the params array of the  
controller, however I do not know in which order.  
Is there a way that my controller can find the order of the params in  
the original url ? Remember, the forum knows nothing of sites or  
users or anything else that either I or another developer wants to  
throw at it.

Hope this makes some sense - I am tired as I am typing this 🙂

Cheers

Gary
