Storage of constants

Hi --

Hello,

For a number of my models I have many constant key value pairs (sometimes dozens). I have considered putting them in the model but it ends up creating a very cluttered model file. Is there an approvaed approach to having an external data file that is associated with a model? Should I use a yaml file of the same name? xml? csv? Recommendations are appreciated.

How about Ruby? :slight_smile: Just define some constants and pull them in at runtime. You can put things in lib/ and then require them from your model file(s), or from the bottom of environment.rb. For example, you could create a file called extra_data.rb:

   module ExtraData      COLORS = %w{ red orange yellow }    end

Then in your model file:

   require 'extra_data'    # now you have access to ExtraData::COLORS.

David