Greg Hauptmann
2007-Jul-01 21:10 UTC
environment.rb usage? use of "Rails::Initializer.run" section block vs outside block? (e.g. where to put constants)
Hi, Can anyone explain the intended usage within "environment.rb" of the areas (a) within the "Rails::Initializer.run do |config| " block section and (b) the area after this block. For example when/what do I include in the "Rails::Initializer.run do |config| " section versus not? As an example say setting up constants. Tks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris T
2007-Jul-04 14:50 UTC
Re: environment.rb usage? use of "Rails::Initializer.run" section block vs outside block? (e.g. where to put constants)
Greg Hauptmann wrote:> Hi, > > Can anyone explain the intended usage within "environment.rb" of the > areas (a) within the "Rails::Initializer.run do |config| " block > section and (b) the area after this block. > > For example when/what do I include in the "Rails:: Initializer.run do > |config| " section versus not? As an example say setting up constants. > > Tks > > > >Have a look at http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet and http://glu.ttono.us/articles/2006/05/22/guide-environments-in-rails-1-1 Hope this helps Chris -- ---------------------------- Autopendium :: Stuff about old cars http://autopendium.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 -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2007-Jul-06 06:33 UTC
Re: environment.rb usage? use of "Rails::Initializer.run" section block vs outside block? (e.g. where to put constants)
thanks Chris, It still didn''t fully clarify things for me however. I see they state: "With the exceptions of the RAILS_GEM_VERSION constant and the setting for what environment to use, the bulk of the configuration in Rails happens within the Rails::Initializer.run block." However I note that in my application I am currently (writely or wrongly) been setting various parameters outside the "Rails::Initializer.run do |config| " block..., e.g. - LOCALES = {''en'' => ''en'', ''fr'' => ''fr''}.freeze - ActionMailer::Base.smtp_settings = { etc - ExceptionNotifier.email_prefix = "xxx" etc - TimeZone.all.each_with_index { |tz, i| $TIME_ZONE_ARRAY << [tz, i.to_s] } - class Logger def format_message(severity, timestamp, progname, msg) etc So it''s still not quite clear to me whether I''m currently following rails best practice or not? Any advice anyone? Tks Greg On 7/5/07, Chris T <ctmailinglists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > Greg Hauptmann wrote: > > Hi, > > > > Can anyone explain the intended usage within "environment.rb" of the > > areas (a) within the "Rails::Initializer.run do |config| " block > > section and (b) the area after this block. > > > > For example when/what do I include in the "Rails:: Initializer.run do > > |config| " section versus not? As an example say setting up constants. > > > > Tks > > > > > > > > Have a look at > > http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet > and > http://glu.ttono.us/articles/2006/05/22/guide-environments-in-rails-1-1 > Hope this helps > Chris > > -- > ---------------------------- > Autopendium :: Stuff about old cars > http://autopendium.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 -~----------~----~----~----~------~----~------~--~---
Chris T
2007-Jul-06 07:38 UTC
Re: environment.rb usage? use of "Rails::Initializer.run" section block vs outside block? (e.g. where to put constants)
I set up all my constants, including ActionMailer settings, after the Rails::Initializer.run block, and I believe this is the correct way to do it. Apart from anything else, I don''t think they don''t require access to the config object which is passed to the block. Cheers Chris Greg Hauptmann wrote:> thanks Chris, > > It still didn''t fully clarify things for me however. I see they > state: "With the exceptions of the RAILS_GEM_VERSION constant and the > setting for what environment to use, the bulk of the configuration in > Rails happens within the Rails:: Initializer.run block." > > However I note that in my application I am currently (writely or > wrongly) been setting various parameters outside the > "Rails::Initializer.run do |config| " block..., e.g. > > * LOCALES = {''en'' => ''en'', ''fr'' => ''fr''}.freeze > * ActionMailer::Base.smtp_settings = { etc > * ExceptionNotifier.email_prefix = "xxx" etc > * TimeZone.all.each_with_index { |tz, i| $TIME_ZONE_ARRAY << [tz, > i.to_s] } > * class Logger > def format_message(severity, timestamp, progname, msg) etc > > So it''s still not quite clear to me whether I''m currently following > rails best practice or not? Any advice anyone? > > > Tks > Greg > > > On 7/5/07, *Chris T* <ctmailinglists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org > <mailto:ctmailinglists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> wrote: > > > Greg Hauptmann wrote: > > Hi, > > > > Can anyone explain the intended usage within "environment.rb" of the > > areas (a) within the "Rails::Initializer.run do |config| " block > > section and (b) the area after this block. > > > > For example when/what do I include in the "Rails:: > Initializer.run do > > |config| " section versus not? As an example say setting up > constants. > > > > Tks > > > > > > > > Have a look at > http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet > and > http://glu.ttono.us/articles/2006/05/22/guide-environments-in-rails-1-1 > Hope this helps > Chris > > -- > ---------------------------- > Autopendium :: Stuff about old cars > http://autopendium.com > > > > > > > >-- ---------------------------- Autopendium :: Stuff about old cars http://autopendium.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 -~----------~----~----~----~------~----~------~--~---