Hi,
Lets assume we have an url, /controller1/action1.
In the before filter, under certain conditions, I want to route it
to /controller2/action2. without changing the url at the client side
ie I donot want to use redirect. Please help.
You really need to give us more information to help. If you want just
the layout from the other action, you can use render. However, render
will not execute the code from the controller's action method; it will
only render the template. If you want to execute the code and truly
redirect, I think you are stuck changing the url. Why do you need to
do this? Let us know a little more of the situation and we might be
able to give you a better solution.
I want to execute the new action as well as render the corresponding
view, without changing the url. It is a case of dynamic routing.
Following is the scenario:
Every user can have their profile on the website, whose url is
www.xyz.com/profileid
Additionally there would be an option for the user to add a domain to
point to their profile.
So for example, my profile on the website is www.xyz.com/pankaj
If I own a domain www.pankaj.com, and point it to www.xyz.com, then
www.pankaj.com should take me to the page www.xyz.com/pankaj without
changing the url.
In the before filter function, I check if the url is not xyz.com, then
it is mapped to the corresponding user, and then I need to go to the
corresponding controller and action.