Joshua Muheim
2006-Aug-16 19:07 UTC
[Rails] Where and how to store app wide settings variables?
Hi all I''d like to know what''s a good way to store app wide settings variables. Because for example I have different fields in models that all should be 20 chars long (validates_length_of :maximum => 20). I don''t want to hard-code that, because in future this could change. So where should I store such vars? In the environment.rb file in constants like...? MAX_NAME_LENGTH = 20 Or are there better ways or even something like a Rails-specific construct for such vars? Thanks for hints. Joshua -- Posted via http://www.ruby-forum.com/.
Andrew Stone
2006-Aug-16 19:15 UTC
[Rails] Where and how to store app wide settings variables?
I don''t know of a standard for such a construct, but I created a constants.rb file in the config directory to hold such information. The environment.rb file loads (require) the constants file. I wanted this separation because there are settings that are server specific ( environment.rb) and some that are constant (constants.rb) regardless of the server. -- Andrew Stone -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060816/5620a581/attachment.html