Thursday, February 21, 2013

Accessing class from another module in Ruby on Rails

Modules in Ruby on Rails are not autoloadable in Ruby on Rails application.

Some hints on how to use a class from another module.

1. To make a module autoloadable the corresponding line should be commented out in application.rb

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

2. Just use "::" before the class
3. Include the module in a code where the class is supposed to be used.

0 коммент.:

Post a Comment

Powered by Blogger.