Skip to content
This repository
Browse code

Conversion of a two dimensional array that is ruby 1.8.6 safe. Fix pa…

…ren warnings too.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit b64d1fe637d16916c59e2ddec403d9c7cd54b0f8 1 parent 6f17422
Ken Collins authored NZKoz committed
2  activerecord/lib/active_record/associations/association_collection.rb
@@ -383,7 +383,7 @@ def method_missing(method, *args)
383 383
             return  send("find_by_#{rest}", *args) ||
384 384
                     method_missing("create_by_#{rest}", *args)
385 385
           when /^create_by_(.*)$/
386  
-            return create Hash[$1.split('_and_').zip(args)]
  386
+            return create($1.split('_and_').zip(args).inject({}) { |h,kv| k,v=kv ; h[k] = v ; h })
387 387
           end
388 388
 
389 389
           if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
4  activerecord/test/cases/associations/has_many_associations_test.rb
@@ -26,7 +26,7 @@ def test_create_by
26 26
     post   = Post.find :first
27 27
 
28 28
     assert_equal [], person.readers
29  
-    assert_nil person.readers.find_by_post_id post.id
  29
+    assert_nil person.readers.find_by_post_id(post.id)
30 30
 
31 31
     reader = person.readers.create_by_post_id post.id
32 32
 
@@ -55,7 +55,7 @@ def test_find_or_create_by
55 55
     post   = Post.find :first
56 56
 
57 57
     assert_equal [], person.readers
58  
-    assert_nil person.readers.find_by_post_id post.id
  58
+    assert_nil person.readers.find_by_post_id(post.id)
59 59
 
60 60
     reader = person.readers.find_or_create_by_post_id post.id
61 61
 

0 notes on commit b64d1fe

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