Where is the best place to initialize global constants that one would like to access from both controllers and models? Initializing them in application.rb doesn''t seem to do the trick. (I could use a before_filter that initializes them, but I would only want it to be called once rather than re-initialize them every single time any method in my application is called.) -- "Impossible is nothing." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
zer0halo wrote:> Where is the best place to initialize global constants that one would like > to access from both controllers and models? Initializing them in > application.rb doesn''t seem to do the trick. (I could use a before_filter > that initializes them, but I would only want it to be called once rather > than re-initialize them every single time any method in my application is > called.)I stuck them in a "helper" style module in lib/ So we might have a choice between - no constants - wrap them in a block that disables the warning - put them in lib/ and bouce the server when they change -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
François Montel wrote:> Where is the best place to initialize global constants that one would > like > to access from both controllers and models? Initializing them in > application.rb doesn''t seem to do the trick. (I could use a > before_filter > that initializes them, but I would only want it to be called once rather > than re-initialize them every single time any method in my application > is > called.) > -- > "Impossible is nothing."Are these global constants not like configuration items? Then it would make sense to define them in config/environment.rb (or load a file with their values from there) Stephan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/4/06, Stephan Wehner <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > Are these global constants not like configuration items? Then it would > make sense to define them in config/environment.rb (or load a file with > their values from there)No, they''re not configuration items, but rather shortcuts for certain values that I use often throughout the app (like global vars). However, you''re right, loading a file in environment.rb is probably the way to go - I hadn''t even thought of that. I''ll give it a try. Thanks. -- "Impossible is nothing." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---