I am a newbie to RoR. I am trying to figure out how to check if a property is defined or not in the environment file(development.rb in this case).
We have a property defined in development.rb file, something like:
config.user = 'test-user'
Now in the code, I use it by calling:
Rails.application.config.user
which gives me the required value.
But the problem is this configuration may be disabled sometimes. So, I want to check if this property is defined or not before assigning it. Something like
user_name = (if Rails.application.config.user is available)?
Rails.application.config.user : 'some_other_value'
I tried defined? and respond_to but did not work.
Any help/suggestions are appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire