Skip to content

Commit b64d1fe

Browse files
metaskillsNZKoz
authored andcommitted
Conversion of a two dimensional array that is ruby 1.8.6 safe. Fix paren warnings too.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
1 parent 6f17422 commit b64d1fe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

activerecord/lib/active_record/associations/association_collection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def method_missing(method, *args)
383383
return send("find_by_#{rest}", *args) ||
384384
method_missing("create_by_#{rest}", *args)
385385
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 })
387387
end
388388

389389
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))

activerecord/test/cases/associations/has_many_associations_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_create_by
2626
post = Post.find :first
2727

2828
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)
3030

3131
reader = person.readers.create_by_post_id post.id
3232

@@ -55,7 +55,7 @@ def test_find_or_create_by
5555
post = Post.find :first
5656

5757
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)
5959

6060
reader = person.readers.find_or_create_by_post_id post.id
6161

0 commit comments

Comments
 (0)