Can anyone set me straight on this? I often put files in lib which add new modules or monkey patch existing classes etc. These always need to be explicitly required in my environment file. That all works, but one of my colleagues believes that everything in lib should be loaded automatically, and that the requires should be necessary. This definitely isn''t the case - if i remove the require then i dont get the extra functionality. Is something going wrong for me? Or are lib files not meant to be loaded automatically? thanks max -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-02 13:07 UTC
Re: Are files in lib supposed to be loaded automatically?
On 2 Mar 2009, at 12:36, Max Williams wrote:> > Can anyone set me straight on this? > > I often put files in lib which add new modules or monkey patch > existing > classes etc. These always need to be explicitly required in my > environment file. That all works, but one of my colleagues believes > that everything in lib should be loaded automatically, and that the > requires should be necessary. This definitely isn''t the case - if i > remove the require then i dont get the extra functionality. > > Is something going wrong for me? Or are lib files not meant to be > loaded automatically?As far as I know they are not loaded automatically in the sense that rails won''t just load them without any intervention from you. They are in the sense that if you say MyModule then rails will try and load my_module.rb in lib (among other places). This of course doesn''t work if what your file contains is a monkey patch. Perhaps these two different meanings of automatically are what are clouding the issue (and on top of all that there''s rails 2.2''s ''load everything on startup'' mode which may or may not grab things from /lib - I can''t remember) Fred> > > thanks > max > -- > 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 -~----------~----~----~----~------~----~------~--~---
Max Williams
2009-Mar-02 14:25 UTC
Re: Are files in lib supposed to be loaded automatically?
Frederick Cheung wrote:> On 2 Mar 2009, at 12:36, Max Williams wrote: > >> >> Is something going wrong for me? Or are lib files not meant to be >> loaded automatically? > > As far as I know they are not loaded automatically in the sense that > rails won''t just load them without any intervention from you. They are > in the sense that if you say MyModule then rails will try and load > my_module.rb in lib (among other places). This of course doesn''t work > if what your file contains is a monkey patch. Perhaps these two > different meanings of automatically are what are clouding the issue > (and on top of all that there''s rails 2.2''s ''load everything on > startup'' mode which may or may not grab things from /lib - I can''t > remember) > > Fredah, ok. i think that explains my confusion - i''d seen some stuff work without being required. We''re using 2.2.2 though and it''s not grabbing everything from lib. cheers max -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-02 14:45 UTC
Re: Are files in lib supposed to be loaded automatically?
On Mar 2, 2:25 pm, Max Williams <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote:> ah, ok. i think that explains my confusion - i''d seen some stuff work > without being required. We''re using 2.2.2 though and it''s not grabbing > everything from lib.I should add that that thing is only turned on in production anyway. Fred> > cheers > max > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---