I am new to Rails (using 3.2.9) and get a NoMethodError I don’t know how to fix. Can anyone help, please?
A NoMethodError occurred in trade_plans#update:
undefined method `[]' for false:FalseClass
app/models/trade_plan.rb:96:in `symbol_is_valid'
And this is line 96 in trade_plan.rb:
if(data[:last_trade_price_only] == "N/A" || data[:last_trade_price_only].blank?)
Any ideas why this error occurs and how to fix it?
Thanks 🙂
That’s probably because your local variable
datahas the valuefalseinstead of being an instance ofHash.Since you are trying to call the method
[]on the objectfalse, it raises aNoMethodErrorbecausefalsedoes not respond to[].