Archive for January 21st, 2009

If you want to use the /lib/ directory in a Ruby on Rails application to store .rb files that contain constants. For some (name spacing / scoping?) reason they must be written in a class declaration:
Contents of /lib/constants.rb
123def ConstantClass
  CONSTANT_NAME = ’some value’
end
Then access these constants using the scope resolution operator in your views/controllers:
1<p><%= ConstantClass::CONSTANT_NAME [...]


top