While I''m in a script/console session I want access to methods I''ve defined in a utilities unit I''ve put in the project/lib directory. I''ve tried requiring the unit and loading the unit but still don''t get the methods. What''s the technique to use in this case? -- 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 Oct 22, 5:15 pm, John Small <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> While I''m in a script/console session I want access to methods I''ve > defined in a utilities unit I''ve put in the project/lib directory. I''ve > tried requiring the unit and loading the unit but still don''t get the > methods. What''s the technique to use in this case? > -- > Posted viahttp://www.ruby-forum.com/.Put them into a module. For instance, I have lib/image_handler.rb. module ImageHandler def self.foo puts ''foo'' end class Image ... end .... end $ script/console Loading development environment (Rails 2.0.2)>> ImageHandler=> ImageHandler>> ImageHandler::Image=> ImageHandler::Image>> ImageHandler.foo=> "foo" -- Daniel Bush --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
John Small
2008-Oct-22 08:47 UTC
Re: using methods in /lib while in script/console session
Daniel Bush wrote:> Put them into a module. > For instance, I have lib/image_handler.rb. > module ImageHandler > def self.foo > puts ''foo'' > end > class Image > ... > end > .... > end >Daniel Ok thanks that worked. John Small -- 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 -~----------~----~----~----~------~----~------~--~---