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?
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 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