As I test my rails application, I’m noticing an increasing amount of the
following warning as I’m testing:
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/validations.rb:74:
warning: Object#type is deprecated; use Object#class
How do I step back and debug this since the warning isn’t in my code?
But, it’s clearly something my code is creating since it does more as I
write more test code.
There’s a few attributes WITH type in the name “question_type”, but none
actually CALLED “type”. Would that still do it? Any other ideas?
Daniel, did you ever find an answer to this one? I’m getting exactly the
same behavior. I have attributes with “type” in the name, but none
exactly named “type”.
There’s a few attributes WITH type in the name “question_type”, but none
actually CALLED “type”. Would that still do it? Any other ideas?
Daniel, did you ever find an answer to this one? I’m getting exactly the
same behavior. I have attributes with “type” in the name, but none
exactly named “type”.
I encountered a similar problem when calling :type on an instance that
(misbehaved and) overrode :type (Mysqlcolumn in this instance). I was
seeing the above error message when I had a nil object and was still
sending type (hence, Object#type handled). The fix was something like:
Before:
find_column(:attribute).type
After:
find_column(:attribute).type if find_column(:attribute)
If you really have a database column called “type”, then you should be
using Single-Table Inheritance (because ActiveRecord is going to make
that assumption). You can change the column that AR expects to use to
a name different than ‘type’ (look it up) or you can reference
u[‘type’] or u[:type] rather than u.type to avoid the warning.