Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 metaskills authored NZKoz committed
2  activerecord/lib/active_record/associations/association_collection.rb
View
@@ -383,7 +383,7 @@ def method_missing(method, *args)
return send("find_by_#{rest}", *args) ||
method_missing("create_by_#{rest}", *args)
when /^create_by_(.*)$/
- return create Hash[$1.split('_and_').zip(args)]
+ return create($1.split('_and_').zip(args).inject({}) { |h,kv| k,v=kv ; h[k] = v ; h })
end
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
4 activerecord/test/cases/associations/has_many_associations_test.rb
View
@@ -26,7 +26,7 @@ def test_create_by
post = Post.find :first
assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id post.id
+ assert_nil person.readers.find_by_post_id(post.id)
reader = person.readers.create_by_post_id post.id
@@ -55,7 +55,7 @@ def test_find_or_create_by
post = Post.find :first
assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id post.id
+ assert_nil person.readers.find_by_post_id(post.id)
reader = person.readers.find_or_create_by_post_id post.id
Please sign in to comment.
Something went wrong with that request. Please try again.