From 074880c4eab3121025840998e587753203f65f6f Mon Sep 17 00:00:00 2001 From: Yuki Nishijima Date: Wed, 15 Oct 2014 17:32:35 -0700 Subject: AR::UnknownAttributeError should include the class name of a record This would be helpful if 2 models have an attribute that has a similar name to the other. e.g: before: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute: name after: User.new(name: "Yuki Nishijima", projects_attributes: [name: "kaminari"]) # => ActiveRecord::UnknownAttributeError: unknown attribute on User: name --- activerecord/lib/active_record/errors.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index 52c70977ef..2b9b3c8f73 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -167,7 +167,7 @@ module ActiveRecord def initialize(record, attribute) @record = record @attribute = attribute.to_s - super("unknown attribute: #{attribute}") + super("unknown attribute on #{@record.class}: #{attribute}") end end -- cgit v1.2.3