How to access YAML sublevel item in a nested variable?
- by Kleber S.
Getting the error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
APP_CONFIG are loading fine.
account_type = 'sample'
allowed = APP_CONFIG['account']["#{account_type}"]['highlight']
Error points to 'allowed' variable line.
The method that I currently trying to is:
def self.allow_highlight?(account)
account_type = Account.find(account).active_pack # returning a string - OK
logger.debug account_type.class # checked on console - OK
allowed = APP_CONFIG['account']["#{account_type}"]['highlight'] # Error line
if total_account_highlight > allowed
false
else
true
end
end
Hope you understand.
Any doubts, please ask me.
Thanks!