diff options
author | Adam Milligan <amilligan@pivotallabs.com> | 2009-05-10 16:20:16 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-06-12 13:52:51 -0700 |
commit | 54a5446641e4386285231385700b95a223931bff (patch) | |
tree | f2c00aac7b43a381ec4bd5f9f5cc26634243fe96 /activerecord/lib/active_record/associations/has_one_through_association.rb | |
parent | 8db190acbae5d2a6f25d42d4137793a720a1689c (diff) | |
download | rails-54a5446641e4386285231385700b95a223931bff.tar.gz rails-54a5446641e4386285231385700b95a223931bff.tar.bz2 rails-54a5446641e4386285231385700b95a223931bff.zip |
HasOneThroughAssociation still shouldn't derive from HasManyThroughAssociation.
[#1642 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
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 |