Following the answer on How to define custom configuration variables in rails, I am trying to set up a configuration settings for different environments in config/environments/{env}.rb
e.g. in development.rb
I set
config.elvis = 'alive'
and then in my haml template I can use this variable, e.g.
Elvis is #{Rails.configuration.elvis}
.
However, when I want to wrap this in a condition:
- if Rails.configuration.elvis
<p>Elvis is #{Rails.configuration.elvis}</p>
it also works, but if the configuration isn't set, it throws a undefined method
error.
If I try instead:
- if defined? Rails.configuration.elvis
<p>Elvis is #{Rails.configuration.elvis}</p>
it seems to always evaluate as false, even with the configuration defined.
Still very new to rails/ruby, so apologies if it's a very dumb question