aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_association.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-06 18:04:32 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-07 15:03:15 -0800
commit770e6893b9f2aaaebe3de10576931dc7194451bc (patch)
treea69337db0ed7743d302a9d54c142efa5447ab810 /activerecord/lib/active_record/associations/has_association.rb
parent441118458d57011ee1b1f1dcfea558de462c6da9 (diff)
downloadrails-770e6893b9f2aaaebe3de10576931dc7194451bc.tar.gz
rails-770e6893b9f2aaaebe3de10576931dc7194451bc.tar.bz2
rails-770e6893b9f2aaaebe3de10576931dc7194451bc.zip
Construct an actual ActiveRecord::Relation object for the association scope, rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things.
Diffstat (limited to 'activerecord/lib/active_record/associations/has_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_association.rb28
1 files changed, 0 insertions, 28 deletions
diff --git a/activerecord/lib/active_record/associations/has_association.rb b/activerecord/lib/active_record/associations/has_association.rb
index 190fed77c2..8b180c7301 100644
--- a/activerecord/lib/active_record/associations/has_association.rb
+++ b/activerecord/lib/active_record/associations/has_association.rb
@@ -9,34 +9,6 @@ module ActiveRecord
construct_owner_attributes.each { |key, value| record[key] = value }
end
end
-
- # Returns a hash linking the owner to the association represented by the reflection
- def construct_owner_attributes(reflection = @reflection)
- attributes = {}
- if reflection.macro == :belongs_to
- attributes[reflection.association_primary_key] = @owner.send(reflection.foreign_key)
- else
- attributes[reflection.foreign_key] = @owner.send(reflection.active_record_primary_key)
-
- if reflection.options[:as]
- attributes["#{reflection.options[:as]}_type"] = @owner.class.base_class.name
- end
- end
- attributes
- end
-
- # Builds an array of arel nodes from the owner attributes hash
- def construct_owner_conditions(table = aliased_table, reflection = @reflection)
- construct_owner_attributes(reflection).map do |attr, value|
- table[attr].eq(value)
- end
- end
-
- def construct_conditions
- conditions = construct_owner_conditions
- conditions << Arel.sql(sql_conditions) if sql_conditions
- aliased_table.create_and(conditions)
- end
end
end
end