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

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.

Thank you for that suggestion. :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs