Christian Schlaefcke
2006-Nov-23 14:18 UTC
Where to place and initialize application params
Hi folks, the first places I can think of are environment.rb and application.rb. I just wonder if these files should be used to configure the rails environment or plugins/engines. If the common way is to do it with environment.rb and application.rb my next question is: how do I access a simple param in environment.rb like "application_name = "My fency rails app" in my application.rb? Thanks & Regards, Christian -- 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 -~----------~----~----~----~------~----~------~--~---
Christian Schlaefcke
2006-Nov-23 14:19 UTC
Re: Where to place and initialize application params
Christian Schlaefcke wrote:> the first places I can think of are environment.rb and application.rb. I > just wonder if these files should be used to configure the rails > environment or plugins/engines. > > If the common way is to do it with environment.rb and application.rb my > next question is: how do I access a simple param in environment.rb like > "application_name = "My fency rails app" in my application.rb?Hmmm, just a thought: Could it be done with YAML, maybe? Christian -- 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 -~----------~----~----~----~------~----~------~--~---
In general, environment.rb *is* the place where you should perform configuration. There''s even a comment at the bottom of the file to that effect :) You need to consider what it is that you''re actually configuring. If it''s some string which acts as the application title, you could place this in a constant: [ environment.rb, at the end ] ApplicationName = "I Caught You A Delicious Bass" and then reference this constant somewhere else. In your example, because ''application_name'' doesn''t start with a capital letter, Ruby assumes that it is a local variable and it is almost certainly lost within the scope of your ApplicationController (the class defined in application.rb). In a nutshell, use constants if you want to set some value that needs to persist in a different part of Rails. You could even define these within a module to keep the top-level namespace clear. On 11/23/06, Christian Schlaefcke <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Christian Schlaefcke wrote: > > the first places I can think of are environment.rb and application.rb. I > > just wonder if these files should be used to configure the rails > > environment or plugins/engines. > > > > If the common way is to do it with environment.rb and application.rb my > > next question is: how do I access a simple param in environment.rb like > > "application_name = "My fency rails app" in my application.rb? > > Hmmm, just a thought: Could it be done with YAML, maybe? > > Christian > > -- > Posted via http://www.ruby-forum.com/. > > > >-- * J * ~ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Christian Schlaefcke wrote: >> the first places I can think of are environment.rb and >> application.rb. I >> just wonder if these files should be used to configure the rails >> environment or plugins/engines. >> >> If the common way is to do it with environment.rb and >> application.rb my >> next question is: how do I access a simple param in environment.rb >> like >> "application_name = "My fency rails app" in my application.rb? > > Hmmm, just a thought: Could it be done with YAML, maybe?Have a look at this: http://www.realityforge.org/articles/2006/02/28/flexible-application- configuration-in-rails 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?hl=en -~----------~----~----~----~------~----~------~--~---
Christian Schlaefcke
2006-Nov-23 15:51 UTC
Re: Where to place and initialize application params
Andrew Stewart wrote:>>> "application_name = "My fency rails app" in my application.rb? >> >> Hmmm, just a thought: Could it be done with YAML, maybe? > > Have a look at this: > > http://www.realityforge.org/articles/2006/02/28/flexible-application- > configuration-in-railsThat looks nice! Thank you, I´ll give it a try. Christian -- 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 -~----------~----~----~----~------~----~------~--~---