I'm curious how best to handle global constants in a Rails application. That is, where do they go? I've seen a couple of possible places -- a module, the 'application.rb'. Let's say I have a user-selectable configuration "config" that is stored in a table as an INTEGER. The user could select among: THIS_WAY = 1 THAT_WAY = 2 ANOTHER_WAY = 3 Rather than testing config==2 through the application, I'd rather do "config=='THAT_WAY'". Am I correct is thinking that my application.rb should have something like: CONFIG_OPTIONS = [ ['THIS_WAY', 1], ['THAT_WAY', 2], ['ANOTHER_WAY', 3] ].freeze Or is there a better method?
on 2005-12-19 23:51