Running one of my test classes using multiparameter attributes (date column in the database) I got a lot of warnings saying:
Here's the code where type is called:
Normally, type should be called on a Column object, which provides a type (see vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb), but in my case, column was nil and the method type was called for Object.
I don't fully understand what's going on (why is column nil?), but as a quickfix to silence the annoying warning you can change the method in attribute_methods.rb to handle this as a special case:
vendor/rails/activerecord/lib/active_record/attribute_methods.rb:142: warning: Object#type is deprecated; use Object#class
Here's the code where type is called:
def create_time_zone_conversion_attribute?(name, column)
time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type)
end
time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type)
end
Normally, type should be called on a Column object, which provides a type (see vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb), but in my case, column was nil and the method type was called for Object.
I don't fully understand what's going on (why is column nil?), but as a quickfix to silence the annoying warning you can change the method in attribute_methods.rb to handle this as a special case:
def create_time_zone_conversion_attribute?(name, column)
if column.nil?
true
else
time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type)
end
end
if column.nil?
true
else
time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type)
end
end