Neeraj Kumar
2007-Jan-26 18:16 UTC
How to put common utils in the app without polluing environment.rb
I have developed some common utils which I use in all my RoR apps. It''s a moule with a lot of utilities. In order t use them currently this is what I do. environment.rb include AppCommonUtils The file app_common_utils reside in lib directory. It works but I don''t like it. In order to use these utilities I need to tinker with the environment.rb of each application. So I put this module as a pluging. But in int init.rb of the plugin I don''t know what to write which will be equivalent of putting the module in the environment.rb. I''m suspecting it will be something along the line of something.send(:include, AppCommonUtils) Could someone help me out with what that something should be here? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Stewart
2007-Jan-29 15:48 UTC
Re: How to put common utils in the app without polluing environment.rb
> I have developed some common utils which I use in all my RoR apps. > It''s a moule with a lot of utilities. In order t use them currently > this is what I do. > > environment.rb > include AppCommonUtils > > > The file app_common_utils reside in lib directory. It works but I > don''t like it. > > In order to use these utilities I need to tinker with the > environment.rb of each application. So I put this module as a pluging. > But in int init.rb of the plugin I don''t know what to write which will > be equivalent of putting the module in the environment.rb. > > I''m suspecting it will be something along the line of > > something.send(:include, AppCommonUtils)Rails will load your AppCommonUtils module automatically without your having to tinker with environment.rb. If you want to include your module, i.e. above and beyond the auto-''require'' I just mentioned, you could try something like this (though I''m not 100% sure about this) inside your module: module AppCommonUtils def self.included(base) base.extend self end end Regards, Andy Stewart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Neeraj Kumar
2007-Jan-31 02:29 UTC
Re: How to put common utils in the app without polluing environment.rb
The module AppCommonUtils needs to be included in environment.rb for it to be invoked. Otherwise I don''t think it''ll work. - Neeraj On 1/29/07, Andrew Stewart <boss-rAnrN1QAkGGttCpgsWEBFlaTQe2KTcn/@public.gmane.org> wrote:> > > > I have developed some common utils which I use in all my RoR apps. > > It''s a moule with a lot of utilities. In order t use them currently > > this is what I do. > > > > environment.rb > > include AppCommonUtils > > > > > > The file app_common_utils reside in lib directory. It works but I > > don''t like it. > > > > In order to use these utilities I need to tinker with the > > environment.rb of each application. So I put this module as a pluging. > > But in int init.rb of the plugin I don''t know what to write which will > > be equivalent of putting the module in the environment.rb. > > > > I''m suspecting it will be something along the line of > > > > something.send(:include, AppCommonUtils) > > Rails will load your AppCommonUtils module automatically without your > having to tinker with environment.rb. > > If you want to include your module, i.e. above and beyond the > auto-''require'' I just mentioned, you could try something like this > (though I''m not 100% sure about this) inside your module: > > module AppCommonUtils > def self.included(base) > base.extend self > end > end > > Regards, > Andy Stewart > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---