Skip to content
This repository
Browse code

Merge pull request #6927 from parndt/patch-3

Make ArgumentError message more consistent in nested attributes
  • Loading branch information...
commit 8ce61a366474b20368f60eb1c7bf31c3b7297873 2 parents a5efd58 + a1ad02a
Carlos Antonio da Silva authored July 05, 2012
4  activerecord/lib/active_record/nested_attributes.rb
@@ -351,7 +351,7 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
351 351
         if respond_to?(method)
352 352
           send(method, attributes.except(*unassignable_keys(assignment_opts)), assignment_opts)
353 353
         else
354  
-          raise ArgumentError, "Cannot build association #{association_name}. Are you trying to build a polymorphic one-to-one association?"
  354
+          raise ArgumentError, "Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?"
355 355
         end
356 356
       end
357 357
     end
@@ -373,7 +373,7 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
373 373
     #   })
374 374
     #
375 375
     # Will update the name of the Person with ID 1, build a new associated
376  
-    # person with the name `John', and mark the associated Person with ID 2
  376
+    # person with the name 'John', and mark the associated Person with ID 2
377 377
     # for destruction.
378 378
     #
379 379
     # Also accepts an Array of attribute hashes:
2  activerecord/test/cases/nested_attributes_test.rb
@@ -196,7 +196,7 @@ def setup
196 196
   end
197 197
 
198 198
   def test_should_raise_argument_error_if_trying_to_build_polymorphic_belongs_to
199  
-    assert_raise_with_message ArgumentError, "Cannot build association looter. Are you trying to build a polymorphic one-to-one association?" do
  199
+    assert_raise_with_message ArgumentError, "Cannot build association `looter'. Are you trying to build a polymorphic one-to-one association?" do
200 200
       Treasure.new(:name => 'pearl', :looter_attributes => {:catchphrase => "Arrr"})
201 201
     end
202 202
   end

0 notes on commit 8ce61a3

Please sign in to comment.
Something went wrong with that request. Please try again.