comparison of Fixnum with nil failed
12,736
Solution 1
a_condition
is probably the nil value that you are failing on.
Solution 2
@claim = Item.find(:something)
unless @claim.nil?
if @claim >= a_condition
do_something
end
end
Is a_condition
nil perhaps?
Solution 3
Using the code you posted, the inside of the unless
statement will definitely not execute if @claim
is nil. If you get the error message you posted on line 3 of that code, it must be because a_condition
is nil, not @claim
.
Comments
-
shajin almost 2 years
I coded like this,
@claim = Item.find(:something) unless @claim.nil? if @claim >= a_condition do_something end end
Even if @claim is a nil value,It is going inside the unless condition and giving the error "comparison of Fixnum with nil failed"
What is the wrong in my code.
-
shajin almost 13 yearsSorry 4 that bad question..a newbie.. :) :)
-
-
sawa almost 13 yearsWhat is your code for? I don't see any difference from the one in the question.