# Custom Site Rule

**URL:** <https://www.ruby-forum.com/t/custom-site-rule/104171>\
**Category:** Rails\
**Created:** [May 14, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/custom-site-rule/104171 "2007-05-14T23:17:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurin1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@laurin1](https://www.ruby-forum.com/u/laurin1)\
**Post date:** [May 14, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/custom-site-rule/104171/1 "2007-05-14T23:17:17Z")

</div>

Hi,

I am looking for an approach to do the following.

I have an app which will serve multiple accounts. In many cases they  
will use the same views.

The public part of each account is served by a public controller, so I  
have an app/views/public/index.rhtml for instance.

In certain cases there will be a custom version of these pages for  
accounts. I would like to be able set up something like  
app/custom/someid/index.rhtml

Is there an easy way to redirect the request so the correct view is  
used. I was thinking of routes but its looking for more like a coding  
job.

Thanks,

Keith

---

<div class="post-metadata">

**Author:** ![laurin1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/919ad9/32.png) [@laurin1](https://www.ruby-forum.com/u/laurin1)\
**Post date:** [May 15, 2007, 5:53am UTC](https://www.ruby-forum.com/t/custom-site-rule/104171/2 "2007-05-15T05:53:53Z")

</div>

Hi,

For what I understand I’m not sure you can do it by using routes.  
Perhaps you can if each type of account have a special controller,  
then in your routes you would have to redirect the /  
special\_account\_controller/action/someid to the correct view. If there  
is no special controller I’m not sure you can do it with the routes  
since I don’t see how you would know the current type of account

If there is no special controller for each account then you can check  
the type of account in the controller and make a redirect if  
necessary.  
Perhaps you can directly link in your view themselves to the righ next  
view (using some helper then else it will be messy quite quickly).  
I think if I were you I would use the second option and make one big  
helper taking the view trying to achieve, the type of account and then  
retourning the correct view. That seems the most DRY way.

My 2 cents.  
Chewbie
