rassom
rassom

Reputation: 2966

NoMethodError in Rails app

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 :)

Upvotes: 0

Views: 143

Answers (1)

Jean-Louis Giordano
Jean-Louis Giordano

Reputation: 1967

That's probably because your local variable data has the value false instead of being an instance of Hash.

Since you are trying to call the method [] on the object false, it raises a NoMethodError because false does not respond to [].

Upvotes: 2

Related Questions