aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-24 13:10:26 +0930
committerGitHub <noreply@github.com>2017-05-24 13:10:26 +0930
commit3a354792a2498e60a7d9934e30b8840ad1719ff6 (patch)
tree0693387ccef54dea19f3d8b43cf14ba0a162ecb7
parent845aabbcd3805420090f8b92b50a4562577cf210 (diff)
parent78ad8098ba46ec59eb0d6e9d1280339e1294e093 (diff)
downloadrails-3a354792a2498e60a7d9934e30b8840ad1719ff6.tar.gz
rails-3a354792a2498e60a7d9934e30b8840ad1719ff6.tar.bz2
rails-3a354792a2498e60a7d9934e30b8840ad1719ff6.zip
Merge pull request #29184 from kirs/nested-attributes-friendly-error
More friendly exception in nested attributes
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb2
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index 01ecd79b8f..3f39fb84e8 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -458,7 +458,7 @@ module ActiveRecord
end
unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array)
- raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
+ raise ArgumentError, "Hash or Array expected for attribute `#{association_name}`, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
end
check_record_limit!(options[:limit], attributes_collection)
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
index b87419d203..5a62cbd3a6 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -752,7 +752,7 @@ module NestedAttributesOnACollectionAssociationTests
exception = assert_raise ArgumentError do
@pirate.send(association_setter, "foo")
end
- assert_equal 'Hash or Array expected, got String ("foo")', exception.message
+ assert_equal %{Hash or Array expected for attribute `#{@association_name}`, got String ("foo")}, exception.message
end
def test_should_work_with_update_as_well