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?
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?
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.