Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

find_target can also go into SingularAssociation

  • Loading branch information...
commit b7594a075637f2d3039b066c282acfcb32126cdf 1 parent f1a15c2
@jonleighton jonleighton authored tenderlove committed
View
4 activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -43,10 +43,6 @@ def replace_keys(record)
@owner[@reflection.foreign_key] = record && record[@reflection.association_primary_key]
end
- def find_target
- scoped.first.tap { |record| set_inverse_instance(record) }
- end
-
def foreign_key_present?
@owner[@reflection.foreign_key]
end
View
4 activerecord/lib/active_record/associations/has_one_association.rb
@@ -27,10 +27,6 @@ def replace(record, save = true)
end
private
- def find_target
- scoped.first.tap { |record| set_inverse_instance(record) }
- end
-
def association_scope
super.order(@reflection.options[:order])
end
View
4 activerecord/lib/active_record/associations/singular_association.rb
@@ -18,6 +18,10 @@ def build(attributes = {})
end
private
+ def find_target
+ scoped.first.tap { |record| set_inverse_instance(record) }
+ end
+
# Implemented by subclasses
def replace(record)
raise NotImplementedError
Please sign in to comment.
Something went wrong with that request. Please try again.