hg
2007-Feb-07 16:41 UTC
How do I make an action available to multiple controllers and views?
I have an action in a controller that I need to make available to other controllers and views. I put the action in ApplicationController and ApplicationHelper but it didn''t work. Thank you for any help. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rajesh Shetty
2007-Feb-07 19:28 UTC
Re: How do I make an action available to multiple controller
Jose Hales-Garcia wrote:> I have an action in a controller that I need to make available to > other controllers and views. > > I put the action in ApplicationController and ApplicationHelper but it > didn''t work. > > Thank you for any help.ApplicationHelper houses methods for your views and not actions. If you want actions to be shared by multiple controllers there are 2 ways of doing this # Put your common action in ApplicationController # Write CommonController which will become a base class for all your domain specific controllers .so it will look something like this class CommonController < ApplicationController def common_action end end class Domain1Controller < CommonController end ... class Domain2Controller < CommonController end Now whenever you call common_action in either domains they will be available for execution so url will like this http://...../domain1/common_action http://...../domain2/common_action Hope this helps -Rajesh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Kathy Van Stone
2007-Feb-07 22:24 UTC
Re: How do I make an action available to multiple controllers and views?
At 11:41 AM 2/7/2007, you wrote:>I have an action in a controller that I need to make available to >other controllers and views. > >I put the action in ApplicationController and ApplicationHelper but it >didn''t work.Try putting the shared code into a module and mixing it in. It worked for me. -Kathy Van Stone kvs-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---