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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Meinlschmidt
2011-Aug-26 17:22 UTC
Re: call a controller action from another controller
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 Cordova wrote:> 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? > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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 ============================================================================== -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve start reading about modules, and it seems to be what I need Thanks for your help On Aug 26, 2:22 pm, Tom Meinlschmidt <to...-ooGa/4BNRfTT2+6r9I86XQ@public.gmane.org> wrote:> 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 Cordova wrote: > > > > > > > > > > > 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? > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://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 > ==============================================================================-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Meinlschmidt
2011-Aug-26 19:18 UTC
Re: call a controller action from another controller
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 Cordova wrote:> I''ve start reading about modules, and it seems to be what I need > > Thanks for your help > > On Aug 26, 2:22 pm, Tom Meinlschmidt <to...-ooGa/4BNRfTT2+6r9I86XQ@public.gmane.org> wrote: >> 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 Cordova wrote: >> >> >> >> >> >> >> >> >> >>> 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? >> >>> -- >>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group athttp://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 >> ==============================================================================> > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > 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 ============================================================================== -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.