How to access YAML sublevel item in a nested variable?

Posted by Kleber S. on Stack Overflow See other posts from Stack Overflow or by Kleber S.
Published on 2011-02-21T14:56:32Z Indexed on 2011/02/21 15:25 UTC
Read the original article Hit count: 192

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!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails-3