Hello Everyone, I would like to add a few configurable values to my application but I am not sure how to do it. I have looked through a few Rails books and tried Google but without any luck. I notice that the final line of config/environment.rb tantalisingly reads: # Include your application configuration below Unfortunately I cannot find any information on how (what format) to add in my configuration and how then to access it from my code. Could anybody please point me in the right direction? Any help would be much appreciated. Thanks and regards, Andy Stewart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/11/06, Andrew Stewart <boss-rAnrN1QAkGGttCpgsWEBFlaTQe2KTcn/@public.gmane.org> wrote:> > > Hello Everyone, > > I would like to add a few configurable values to my application but I > am not sure how to do it. I have looked through a few Rails books > and tried Google but without any luck. > > I notice that the final line of config/environment.rb tantalisingly > reads: > > # Include your application configuration below > > Unfortunately I cannot find any information on how (what format) to > add in my configuration and how then to access it from my code. > Could anybody please point me in the right direction? > > Any help would be much appreciated. > > Thanks and regards, > Andy StewartThis is certainly the place to put configuration information. This is just pure ruby so you might put som constants or even methods here, thjs is then available everywhere in your app. (I think) Hope that helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello Andrew, 2006/10/11, Andrew Stewart <boss@airbladesoftware.com>:> # Include your application configuration below > > Any help would be much appreciated.You have a few options. If you want static configuration, then yes, Ruby code in environment.rb is fine. If you want the users to be able to change some or all of the configuration, you'll need to either develope your own Configuration model and store that in the database (or a YAML file, or any other way), or use one of the available plugins. I haven't tried any of the plugins, because I developed my own version of Configuration before they were available. Can't help you there. Hope that helps ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''d like to emphasize Francois'' point about environment.rb being for static configuration. Environment.rb is loaded once at application start and never re-examined. Changes to any paramenter require a server restart to take effect. I use the YAML approach for a menuing system I wrote, and occasionally I''ll use a database. Someone was talking about an acts_as_hash plugin, which would be ideal for settings where you''d like to make a change but not restart the server. Hope this helps. Andrew Stewart-6 wrote:> > > Hello Everyone, > > I would like to add a few configurable values to my application but I > am not sure how to do it. I have looked through a few Rails books > and tried Google but without any luck. > > I notice that the final line of config/environment.rb tantalisingly > reads: > > # Include your application configuration below > > Unfortunately I cannot find any information on how (what format) to > add in my configuration and how then to access it from my code. > Could anybody please point me in the right direction? > > Any help would be much appreciated. > > Thanks and regards, > Andy Stewart > > > > > >-- View this message in context: http://www.nabble.com/How-To-Add-Extra-Application-Configuration-tf2422957.html#a6764032 Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---
> I''d like to emphasize Francois'' point about environment.rb being > for static > configuration. Environment.rb is loaded once at application start > and never > re-examined. Changes to any paramenter require a server restart to > take > effect. I use the YAML approach for a menuing system I wrote, and > occasionally I''ll use a database. Someone was talking about an > acts_as_hash > plugin, which would be ideal for settings where you''d like to make > a change > but not restart the server.Thank you everyone for your replies. It''s been useful to hear your views. I''m just after static configuration on a per-environment basis, so for now I''m simply going to put constants in config/environments/*.rb and access those directly from my application code. Thanks again for your advice and suggestions, Andy Stewart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This is how I implemented it. I got the idea from this mailing list. In environment.rb # Site wide variables # # SITE_YAML[RAILS_ENV][''download_aviable_for''] # SITE_YAML = YAML::load_file("#{RAILS_ROOT}/config/site.yml") Then in site.yml development: download_aviable_for : 24 test: download_aviable_for : 24 production download_aviable_for : 24 regards, Leon Leslie. On 10/12/06, Andrew Stewart <boss-rAnrN1QAkGGttCpgsWEBFlaTQe2KTcn/@public.gmane.org> wrote:> > > > > I''d like to emphasize Francois'' point about environment.rb being > > for static > > configuration. Environment.rb is loaded once at application start > > and never > > re-examined. Changes to any paramenter require a server restart to > > take > > effect. I use the YAML approach for a menuing system I wrote, and > > occasionally I''ll use a database. Someone was talking about an > > acts_as_hash > > plugin, which would be ideal for settings where you''d like to make > > a change > > but not restart the server. > > Thank you everyone for your replies. It''s been useful to hear your > views. > > I''m just after static configuration on a per-environment basis, so > for now I''m simply going to put constants in config/environments/*.rb > and access those directly from my application code. > > Thanks again for your advice and suggestions, > Andy Stewart > > > >-- Never be afraid to try something new. Remember, amateurs built the ark; professionals built the Titanic! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---