I have some additional Array methods I would like to make available, but I can''t figure out how to load them. Thanks for the help. -- 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 -~----------~----~----~----~------~----~------~--~---
On 27 Aug 2008, at 07:25, Chris Olsen wrote:> > I have some additional Array methods I would like to make available, > but > I can''t figure out how to load them.require the file containing them. Fred --~--~---------~--~----~------------~-------~--~----~ 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 wrote:> On 27 Aug 2008, at 07:25, Chris Olsen wrote: > >> >> I have some additional Array methods I would like to make available, >> but >> I can''t figure out how to load them. > > require the file containing them. > > FredWhich is what I did. I thought rails provided a way to auto load them at startup. -- 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 -~----------~----~----~----~------~----~------~--~---
On 27 Aug 2008, at 08:03, Chris Olsen wrote:> > Frederick Cheung wrote: >> On 27 Aug 2008, at 07:25, Chris Olsen wrote: >> >>> >>> I have some additional Array methods I would like to make available, >>> but >>> I can''t figure out how to load them. >> >> require the file containing them. >> >> Fred > > Which is what I did. I thought rails provided a way to auto load them > at startup.Well files in config/initializers are run on startup, you could require it from there, other than that you are going to have to put that require statement somewhere. Fred
Frederick Cheung wrote:> On 27 Aug 2008, at 08:03, Chris Olsen wrote: > >>> >>> Fred >> >> Which is what I did. I thought rails provided a way to auto load them >> at startup. > > > Well files in config/initializers are run on startup, you could > require it from there, other than that you are going to have to put > that require statement somewhere. > > FredAh, I see. I was trying to add it to the load paths. Thanks for the help -- 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 -~----------~----~----~----~------~----~------~--~---
Chris Olsen wrote:> Which is what I did. I thought rails provided a way to auto load them > at startup.The auto loader only works like this. Here''s the first time the interpreter sees Foo: foo = Foo.new That raises an exception which Rails catches. Then it tries to require ''foo'', based on the missing constant name. That trick works only for things with a name. If foo.rb contains Bar, then the first instance of Bar, before a Foo, for any given interpretation, will not load foo.rb, and will propagate the exception. You gotta remember this rule when building libraries. You could ensure Foo appears above Bar in every module, or you could require ''foo'' explicitly. And we put extensions to Ruby classes in environment.rb, but that might just be laziness! -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
did you try with require ''lib/yourfile'' in the application.html.erb file? On Aug 27, 2:25 am, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have some additional Array methods I would like to make available, but > I can''t figure out how to load them. > > Thanks for the help. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---