How to render from a different controller


#1

My code is something like this.

class FirstController < ApplicationController

def foo
#some processing
render (:controller => ‘second’, :action => ‘index’)
end

end

I tried using both render and redirect but it seems it’s not possible to
send the control from within a controller to some other controller. Am
I
missing something here?

Thanks.
-=- Neeraj


#2

Are your redirect_to or render statements the last line in your
controller
method that is performing the redirect? Are you always redirecting, or
doing it conditionally? redirect_to and render do not return a value,
so
your controller method will continue to run after calling them (if there
are
additional statements to process), unless you do something like the
following:

redirect_to :controller => ‘controller’, :action => ‘myAction’ and
return

I’m a relative rails newb, so I could be horribly misleading you, but I
ran
into a similar problem and the above suggestion took care of it…
hopefully someone with more experience can weigh in here for a
definitive
answer.

-Will