aboutsummaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorMatthew Erhard <merhard@gmail.com>2016-05-11 13:09:34 -0400
committerMatthew Erhard <merhard@gmail.com>2016-05-11 13:21:01 -0400
commit556e530da41dce5ae8070e8e075390bbedb949c0 (patch)
tree356ccae535f0a627119a11a8e1cd23f6be829a13 /tasks
parent59d252196b36f6afaafd231756d69ea21537cf5d (diff)
downloadrails-556e530da41dce5ae8070e8e075390bbedb949c0.tar.gz
rails-556e530da41dce5ae8070e8e075390bbedb949c0.tar.bz2
rails-556e530da41dce5ae8070e8e075390bbedb949c0.zip
Define ActiveRecord::Attribute::Null#type_cast
Using ActiveRecord::Base.attribute to declare an attribute with a default value on a model where the attribute is not backed by the database would raise a NotImplementedError when model.save is called. The error originates from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L84. This is called from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L46 on an ActiveRecord::Attribute::Null object. This commit corrects the behavior by implementing ActiveRecord::Attribute::Null#type_cast. With ActiveRecord::Attribute::Null#type_cast defined, ActiveRecord::Attribute::Null#value (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L173..L175) can be replaced with its super method (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L36..L40). fixes #24979
Diffstat (limited to 'tasks')
0 files changed, 0 insertions, 0 deletions