redirect without changing url

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.

Regards,
Pankaj

I would suggest using render instead of redirect.

<%= render :partial => "controller2/action2" %>

Checkout this page for more info: http://api.rubyonrails.org/classes/ActionView/Partials.html

class FooController < ApplicationController
  before_filter :maybe_redirect

  protected

   def maybe_redirect
      redirect_to your_url
      false
   end
end

Hey

You can do Controller2.new.action2, but that's not quite beautiful ..
more over what your action2 will do after finish ? redirect ? render ?

Regards

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.

Good luck,

Andrew

thanks for your replies,

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.

Regards,
Pankaj

can metal or rack be helpful in this?

can metal or rack be helpful in this?