Hi, I''d like to group a set of helpers in a module (just to get a namespace happening) The helpers should be available throughout the app. Where would I put my module and how would I call the methods from my view? I thought the obvious things was this: module ApplicationHelper module MyModule def some_helper() ''hows it going?'' end end end But doing <%=MyModule::some_helper%> in my view doesn''t work. Any hints? Jeroen -- 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 -~----------~----~----~----~------~----~------~--~---
lib/my_module.rb: module MyModule def self.my_helper ''Hello'' end end On 29/08/06, Jeroen Houben <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, > > I''d like to group a set of helpers in a module (just to get a namespace > happening) > > The helpers should be available throughout the app. Where would I put my > module and how would I call the methods from my view? > > I thought the obvious things was this: > > module ApplicationHelper > module MyModule > def some_helper() > ''hows it going?'' > end > end > end > > But doing <%=MyModule::some_helper%> in my view doesn''t work. > > Any hints? > > Jeroen > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Then require ''my_module'' in the places you want to use the helpers or put in in the environment.rb to make it application wide. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---