Call a controller action from another controller

Hi people

I want to know if it is possible to call an action that belongs to a
controller from another action that belongs to a different controller.

I have the “search” action in the controller of Model A , and I need
to cal that action from the action “register”, but action “register”
belongs to the controler of Model B. Also I need to pass some
parameters from action register to execute action search

Is that possible?

create a module and move that method here. then just include into your
controllers and use

tom

On Aug 26, 2011, at 18:29 , Angelo C. wrote:

Is that possible?


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz

I’ve start reading about modules, and it seems to be what I need

Thanks for your help

just create my_module.rb in lib/

module MyModule

def my_method

end
end

and in your controller just

class MyController < ApplicationController
include MyModule

def search
my_method(params)
end

end

just check whether your module is loaded or add require to your
config/environment.rb file

tom

On Aug 26, 2011, at 20:49 , Angelo C. wrote:

I want to know if it is possible to call an action that belongs to a
You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz