diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-06-12 18:09:48 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-06-12 18:09:48 -0300 |
commit | 34a068d053c7268caad78d4f1f90ab0e2a38682f (patch) | |
tree | b991236ba7b29ed4a44d4cb0b79c09c2185f4242 /activerecord/lib/active_record/associations/has_one_through_association.rb | |
parent | a924b2f66e955dcc82b691ca5e48ef5b84035286 (diff) | |
parent | 54a5446641e4386285231385700b95a223931bff (diff) | |
download | rails-34a068d053c7268caad78d4f1f90ab0e2a38682f.tar.gz rails-34a068d053c7268caad78d4f1f90ab0e2a38682f.tar.bz2 rails-34a068d053c7268caad78d4f1f90ab0e2a38682f.zip |
Leave the quoting part to ARel
Diffstat (limited to 'activerecord/lib/active_record/associations/has_one_through_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_through_association.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_through_association.rb b/activerecord/lib/active_record/associations/has_one_through_association.rb index d93c8e7852..830aa1808a 100644 --- a/activerecord/lib/active_record/associations/has_one_through_association.rb +++ b/activerecord/lib/active_record/associations/has_one_through_association.rb @@ -1,6 +1,16 @@ +require "active_record/associations/through_association_scope" + module ActiveRecord module Associations - class HasOneThroughAssociation < HasManyThroughAssociation + class HasOneThroughAssociation < HasOneAssociation + include ThroughAssociationScope + + def replace(new_value) + create_through_record(new_value) + @target = new_value + end + + private def create_through_record(new_value) #nodoc: klass = @reflection.through_reflection.klass @@ -15,16 +25,8 @@ module ActiveRecord end private - def find(*args) - super(args.merge(:limit => 1)) - end - def find_target - super.first - end - - def reset_target! - @target = nil + with_scope(construct_scope) { @reflection.klass.find(:first) } end end end |