Forum: Ruby on Rails How to render from a different controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Neeraj K. (Guest)
on 2006-01-14 22:11
(Received via mailing list)
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
Will B. (Guest)
on 2006-01-14 22:17
(Received via mailing list)
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
This topic is locked and can not be replied to.