diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-16 19:49:32 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-16 13:43:53 -0800 |
commit | b7594a075637f2d3039b066c282acfcb32126cdf (patch) | |
tree | 603531990cc646a3dc76deb8a64c481ae3d2bde4 | |
parent | f1a15c2197d5da8e0c38bd59aa19973c9cfc0a01 (diff) | |
download | rails-b7594a075637f2d3039b066c282acfcb32126cdf.tar.gz rails-b7594a075637f2d3039b066c282acfcb32126cdf.tar.bz2 rails-b7594a075637f2d3039b066c282acfcb32126cdf.zip |
find_target can also go into SingularAssociation
3 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index 271112bbe1..e80b945dda 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -43,10 +43,6 @@ module ActiveRecord @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 diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index 892a8b5bfb..6614cbbf18 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -27,10 +27,6 @@ module ActiveRecord end private - def find_target - scoped.first.tap { |record| set_inverse_instance(record) } - end - def association_scope super.order(@reflection.options[:order]) end diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb index 4b457bd881..b6f49c6f36 100644 --- a/activerecord/lib/active_record/associations/singular_association.rb +++ b/activerecord/lib/active_record/associations/singular_association.rb @@ -18,6 +18,10 @@ module ActiveRecord end private + def find_target + scoped.first.tap { |record| set_inverse_instance(record) } + end + # Implemented by subclasses def replace(record) raise NotImplementedError |