aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-11-30 12:47:31 -0500
committerSean Griffin <sean@seantheprogrammer.com>2016-11-30 12:47:31 -0500
commit1bdc395d956f789b6612796ac6f130cde90d3066 (patch)
tree966c7f055a5ba9c8fcab9cf648c6def189484e76 /activerecord/lib
parentef993d36bc952046f312a3695617eaa6d5fe352e (diff)
downloadrails-1bdc395d956f789b6612796ac6f130cde90d3066.tar.gz
rails-1bdc395d956f789b6612796ac6f130cde90d3066.tar.bz2
rails-1bdc395d956f789b6612796ac6f130cde90d3066.zip
Make the second argument to `attribute` optional
While working on updating Paper Trail for 5.1 compatibility, I noticed that I was required to pass a second argument to `attribute`. I didn't intend for this to be the case, as `attribute :foo` is totally reasonable shorthand for "I want `attr_accessor :foo`, but also have it work with things like `.attributes` and `ActiveRecord::Dirty`"
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attributes.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attributes.rb b/activerecord/lib/active_record/attributes.rb
index dcbfca1c04..75f5ba3a96 100644
--- a/activerecord/lib/active_record/attributes.rb
+++ b/activerecord/lib/active_record/attributes.rb
@@ -191,7 +191,7 @@ module ActiveRecord
# tracking is performed. The methods +changed?+ and +changed_in_place?+
# will be called from ActiveModel::Dirty. See the documentation for those
# methods in ActiveModel::Type::Value for more details.
- def attribute(name, cast_type, **options)
+ def attribute(name, cast_type = Type::Value.new, **options)
name = name.to_s
reload_schema_from_cache