aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_one_association.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-06-12 17:30:56 -0300
committerJeremy Kemper <jeremy@bitsweat.net>2009-06-12 13:45:25 -0700
commit8db190acbae5d2a6f25d42d4137793a720a1689c (patch)
tree9fd56b9c5d823bb62efb6cb677661de1d85f4da7 /activerecord/lib/active_record/associations/has_one_association.rb
parent8f7c657f4b1c037348b24f0b9dd1e45099fbc760 (diff)
downloadrails-8db190acbae5d2a6f25d42d4137793a720a1689c.tar.gz
rails-8db190acbae5d2a6f25d42d4137793a720a1689c.tar.bz2
rails-8db190acbae5d2a6f25d42d4137793a720a1689c.zip
HasOneAssociation inherits AssociationProxy since it shares nothing with BelongsToAssociation.
[#2796 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/associations/has_one_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index b72b84343b..c2568d0c0c 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -1,6 +1,6 @@
module ActiveRecord
module Associations
- class HasOneAssociation < BelongsToAssociation #:nodoc:
+ class HasOneAssociation < AssociationProxy #:nodoc:
def initialize(owner, reflection)
super
construct_sql
@@ -77,7 +77,7 @@ module ActiveRecord
the_target = @reflection.klass.find(:first,
:conditions => @finder_sql,
:select => @reflection.options[:select],
- :order => @reflection.options[:order],
+ :order => @reflection.options[:order],
:include => @reflection.options[:include],
:readonly => @reflection.options[:readonly]
)
@@ -88,7 +88,7 @@ module ActiveRecord
def construct_sql
case
when @reflection.options[:as]
- @finder_sql =
+ @finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
else
@@ -96,7 +96,7 @@ module ActiveRecord
end
@finder_sql << " AND (#{conditions})" if conditions
end
-
+
def construct_scope
create_scoping = {}
set_belongs_to_association_for(create_scoping)
@@ -113,7 +113,7 @@ module ActiveRecord
end
if replace_existing
- replace(record, true)
+ replace(record, true)
else
record[@reflection.primary_key_name] = @owner.id unless @owner.new_record?
self.target = record