Permalink
Browse files

extract record fetching to a method for belongs_to

  • Loading branch information...
1 parent 94cd2f7 commit bdd64912ac80818d338c2c7fea224b0b243ac5d4 @tenderlove tenderlove committed Apr 22, 2014
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/associations/singular_association.rb
@@ -38,8 +38,12 @@ def create_scope
scope.scope_for_create.stringify_keys.except(klass.primary_key)
end
+ def get_records
+ scope.limit(1).to_a
+ end
+
def find_target
- if record = scope.take
+ if record = get_records.first
set_inverse_instance record
end
end

0 comments on commit bdd6491

Please sign in to comment.