I need to use some functionality that I''ve added to the Hash class in an initializer. I''ve written the functionality into /lib/hash.rb; however, rails apparently loads the files in /lib after the initializers as the methods are not there to use in the initializer. I''ve used a require statement at the top of the initializer to get the functionality... require File.join(RAILS_ROOT, ''lib'', ''hash'') It works and no warnings are being thrown in the log; however, since rails doesn''t load them until after the initializers, I wanted to ask... Is this unsafe in some way? -- TW --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 19, 10:08 pm, tekwiz <twarl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I need to use some functionality that I''ve added to the Hash class in > an initializer. I''ve written the functionality into /lib/hash.rb; > however, rails apparently loads the files in /lib after the > initializers as the methods are not there to use in the initializer. >Except perhaps in production mode, rails won''t magically load files from lib for you (and event then that loading happens before initializers run)> I''ve used a require statement at the top of the initializer to get the > functionality... > require File.join(RAILS_ROOT, ''lib'', ''hash'')Just require ''hash'' would do Fred> > It works and no warnings are being thrown in the log; however, since > rails doesn''t load them until after the initializers, I wanted to > ask... Is this unsafe in some way? > > -- TW--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ahh, I see! Thanks Fred! -- TW On Mar 19, 5:25 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 19, 10:08 pm, tekwiz <twarl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I need to use some functionality that I''ve added to the Hash class in > > an initializer. I''ve written the functionality into /lib/hash.rb; > > however, rails apparently loads the files in /lib after the > > initializers as the methods are not there to use in the initializer. > > Except perhaps in production mode, rails won''t magically load files > from lib for you (and event then that loading happens before > initializers run) > > > I''ve used a require statement at the top of the initializer to get the > > functionality... > > require File.join(RAILS_ROOT, ''lib'', ''hash'') > > Just require ''hash'' would do > > Fred > > > > > It works and no warnings are being thrown in the log; however, since > > rails doesn''t load them until after the initializers, I wanted to > > ask... Is this unsafe in some way? > > > -- TW--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---