aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/coders
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2017-01-29 17:24:44 -0500
committerKir Shatrov <shatrov@me.com>2017-01-29 17:24:44 -0500
commit99820fbeb29ae35a7771f3991bd119b102861aa7 (patch)
tree8a0240a6b6d8bc7933fdd9208d00a51d1f744db7 /activerecord/lib/active_record/coders
parent20107ff6c80a7e162adf22176eee811a59498126 (diff)
downloadrails-99820fbeb29ae35a7771f3991bd119b102861aa7.tar.gz
rails-99820fbeb29ae35a7771f3991bd119b102861aa7.tar.bz2
rails-99820fbeb29ae35a7771f3991bd119b102861aa7.zip
Report the attribute on ActiveRecord::SerializationTypeMismatch
Diffstat (limited to 'activerecord/lib/active_record/coders')
-rw-r--r--activerecord/lib/active_record/coders/yaml_column.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/coders/yaml_column.rb b/activerecord/lib/active_record/coders/yaml_column.rb
index 4b06987f08..2136da43fe 100644
--- a/activerecord/lib/active_record/coders/yaml_column.rb
+++ b/activerecord/lib/active_record/coders/yaml_column.rb
@@ -5,7 +5,8 @@ module ActiveRecord
class YAMLColumn # :nodoc:
attr_accessor :object_class
- def initialize(object_class = Object)
+ def initialize(attr_name, object_class = Object)
+ @attr_name = attr_name
@object_class = object_class
check_arity_of_constructor
end
@@ -31,7 +32,7 @@ module ActiveRecord
def assert_valid_value(obj)
unless obj.nil? || obj.is_a?(object_class)
raise SerializationTypeMismatch,
- "Attribute was supposed to be a #{object_class}, but was a #{obj.class}. -- #{obj.inspect}"
+ "Attribute `#{@attr_name}` was supposed to be a #{object_class}, but was a #{obj.class}. -- #{obj.inspect}"
end
end