Skip to content

Commit

Permalink
Merge pull request #6927 from parndt/patch-3
Browse files Browse the repository at this point in the history
Make ArgumentError message more consistent in nested attributes
  • Loading branch information
carlosantoniodasilva committed Jul 6, 2012
2 parents a5efd58 + a1ad02a commit 8ce61a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/nested_attributes.rb
Expand Up @@ -351,7 +351,7 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
if respond_to?(method) if respond_to?(method)
send(method, attributes.except(*unassignable_keys(assignment_opts)), assignment_opts) send(method, attributes.except(*unassignable_keys(assignment_opts)), assignment_opts)
else else
raise ArgumentError, "Cannot build association #{association_name}. Are you trying to build a polymorphic one-to-one association?" raise ArgumentError, "Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?"
end end
end end
end end
Expand All @@ -373,7 +373,7 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
# }) # })
# #
# Will update the name of the Person with ID 1, build a new associated # Will update the name of the Person with ID 1, build a new associated
# person with the name `John', and mark the associated Person with ID 2 # person with the name 'John', and mark the associated Person with ID 2
# for destruction. # for destruction.
# #
# Also accepts an Array of attribute hashes: # Also accepts an Array of attribute hashes:
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/nested_attributes_test.rb
Expand Up @@ -196,7 +196,7 @@ def setup
end end


def test_should_raise_argument_error_if_trying_to_build_polymorphic_belongs_to def test_should_raise_argument_error_if_trying_to_build_polymorphic_belongs_to
assert_raise_with_message ArgumentError, "Cannot build association looter. Are you trying to build a polymorphic one-to-one association?" do assert_raise_with_message ArgumentError, "Cannot build association `looter'. Are you trying to build a polymorphic one-to-one association?" do
Treasure.new(:name => 'pearl', :looter_attributes => {:catchphrase => "Arrr"}) Treasure.new(:name => 'pearl', :looter_attributes => {:catchphrase => "Arrr"})
end end
end end
Expand Down

0 comments on commit 8ce61a3

Please sign in to comment.