# Undefined method \`convert\_to' for false:FalseClass

**URL:** <https://www.ruby-forum.com/t/undefined-method-convert-to-for-false-falseclass/77136>\
**Category:** Ruby\
**Created:** [March 6, 2006, 4:19am UTC](https://www.ruby-forum.com/t/undefined-method-convert-to-for-false-falseclass/77136 "2006-03-06T04:19:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3be4f8/32.png) [@dean](https://www.ruby-forum.com/u/dean)\
**Post date:** [March 6, 2006, 4:19am UTC](https://www.ruby-forum.com/t/undefined-method-convert-to-for-false-falseclass/77136/1 "2006-03-06T04:19:16Z")

</div>

I have a rails app (so maybe this is a question for the rails list) that  
uses a temperature class I also wrote. When the app goes to save a new  
record, I get this error message.

undefined method `convert\_to’ for false:FalseClass

Why is convert\_to being passed a flase object? The method is:

def ==(t\_obj)  
@temp == t\_obj.convert\_to(@units).temp  
end

the convert\_to method converts a temperature object to the requested  
units (C, F, K).  
It is coming from:

#{RAILS\_ROOT}/app/models/temperature.rb:82:in `==' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/callbacks.rb:248:in`create\_or\_update’

Regards,  
–Dean

---

<div class="post-metadata">

**Author:** ![dean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3be4f8/32.png) [@dean](https://www.ruby-forum.com/u/dean)\
**Post date:** [March 6, 2006, 6:21am UTC](https://www.ruby-forum.com/t/undefined-method-convert-to-for-false-falseclass/77136/2 "2006-03-06T06:21:14Z")

</div>

Dean wrote:

> I have a rails app (so maybe this is a question for the rails list) that  
> uses a temperature class I also wrote. When the app goes to save a new  
> record, I get this error message.
> 
> undefined method `convert\_to’ for false:FalseClass
> 
> Why is convert\_to being passed a flase object? The method is:

It could just be Rails weirdness. Paste the code where the call  
is, if at all possible. In the meanwhile, try this workaround to  
see if this is a problem or just something Rails did not expect  
you to do:

> def ==(t\_obj)  
> @temp == t\_obj.convert\_to(@units).temp  
> end

def ==(other)  
other and @temp == other.convert\_to(@units).temp  
end

Here we fail immediately if other is nil or false.

> the convert\_to method converts a temperature object to the requested  
> units (C, F, K).  
> It is coming from:
> 
> #{RAILS\_ROOT}/app/models/temperature.rb:82:in `==' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/callbacks.rb:248:in`create\_or\_update’
> 
> Regards,  
> –Dean

E
