Is there a way to redirect from one controller action to another without a server trip?


I want one controller action to invoke another action in another
controller, but I don't want the overhead of a redirect_to response
which then generates another request to the correct action and
controller. Any suggestions?


Create object for that controller then call.
class A
def a1** invoke.action(args)**


class B
def action(args)





something like

render :controller => othercontroller, :action => :otheraction, :params
=> params


(preserving the params would be a sweet bonus :slight_smile:

something like

render :controller => othercontroller, :action => :otheraction, :params

=> params
Nope, I hope you cant call another controller action like this.

Thanks for the comments guys.

If there is not wasy way to bounce to another controller/action then
there should be. Its available via redirect_to, and one can render the
partials of another controllers actions, but it seems one cant quite
just get the action code to execute.

My usage case is this:

I am writing a web based simple text chat app. People submit comments,
calling the AddComment action, which updates the conversation, and
renders the comment to the people having the conversations.

I want to build in some predefined keywords that will get recognised in
the AddComment action, but will call another controller. Eg I have a
documents controller with a AttachDoc action which gets called normally
when the user clicks on the right button.

I now want to allow doc attachment from the commandline - So when
someone types 'AttachDoc' as a comment, controll should jump to the
documentscontroller. Redirect_to will do the job, but with a unnecessary
trip back to the user.

Still reading? thanks! Any suggestion?

Without thinking too much about it, how about if you create another
class that both your controllers can use?

# This class processes your actions
class YourActionClass
  def your_action(params)
    # here you process your request

# This is the controller you want to process the "redirect".
class ControllerA < ApplicationController
  def your_action
    your_action_instance =

# This is the controller you want to recognize your special cases and
redirect them.
class ControllerB < ApplicationController
  def action
    if special_case
      your_action_instance =
      # maybe you can render something here?
       # your regular stuff goes here.