I have a Rails site that needs to have global access to some settings
which I would like to set in a separate file, e.g. the location of a
companion server. I have done this in a couple of ways but none of
them seems to be very elegant or Ruby-like. Does anyone have any input
on the best practice of dealing with data of this kind.
Thank you for the suggestion. I tried environment.rb but I think it is
not a nice solution because of the discrepancy in data types. The
settings in environment.rb is mostly directives on hov the server
should act and updates require restarting the server. What I would
like is a separate file for settings regarding the application itself,
not the server on which it is run. A trivial difference perhaps, but I
think it is an important one. I don't like setting the preferred
graphics format for user uploads in the same place as where I set e.g.
which parts of Rails to use. I will use this solution if there are no
good alternatives but I have a feeling there are.
This sounds interesting. Could you give a more detailed example. Do
you use module variables or module instance variables, where do you
include it and so on. Do you know of any articles on this subject. I
would be very thankful for the assistance.
This sounds interesting. Could you give a more detailed example. Do
you use module variables or module instance variables, where do you
include it and so on. Do you know of any articles on this subject. I
would be very thankful for the assistance.
- Use the app_config plugin to get a nice syntax
- Add a line in config/environment.rb to 'require application'
- Put the app_config stuff in config/application.rb
I think that'll work, unless 'require application' ends up loading one of
the other application.rb files due to load path order, in which case you
should be able to do something like require "#{config_dir}/application".