aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/through_association_scope.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-10-17 23:29:56 +0100
committerJon Leighton <j@jonathanleighton.com>2010-10-17 23:29:56 +0100
commit78b8c51cb3b0c629152f3bbaf6d8bcf988cc936e (patch)
treeeae58b0877ee952c7a1809c02ad19ea7762e6440 /activerecord/lib/active_record/associations/through_association_scope.rb
parentedc176d33be9499f4c096779c5b4711b5daf0c06 (diff)
downloadrails-78b8c51cb3b0c629152f3bbaf6d8bcf988cc936e.tar.gz
rails-78b8c51cb3b0c629152f3bbaf6d8bcf988cc936e.tar.bz2
rails-78b8c51cb3b0c629152f3bbaf6d8bcf988cc936e.zip
Refactoring: replace the mix of variables like @finder_sql, @counter_sql, etc with just a single scope hash (created on initialization of the proxy). This is now used consistently across all associations. Therefore, all you have to do to ensure finding/counting etc is done correctly is implement the scope correctly.
Diffstat (limited to 'activerecord/lib/active_record/associations/through_association_scope.rb')
-rw-r--r--activerecord/lib/active_record/associations/through_association_scope.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb
index 51ab8869ed..261b4037a3 100644
--- a/activerecord/lib/active_record/associations/through_association_scope.rb
+++ b/activerecord/lib/active_record/associations/through_association_scope.rb
@@ -7,9 +7,8 @@ module ActiveRecord
protected
- def construct_scope
- scope = {}
- scope[:find] = {
+ def construct_find_scope
+ {
:conditions => construct_conditions,
:joins => construct_joins,
:include => @reflection.options[:include] || @reflection.source_reflection.options[:include],
@@ -18,8 +17,10 @@ module ActiveRecord
:limit => @reflection.options[:limit],
:readonly => @reflection.options[:readonly]
}
- scope[:create] = construct_owner_attributes(@reflection) unless @reflection.nested?
- scope
+ end
+
+ def construct_create_scope
+ @reflection.nested? ? {} : construct_owner_attributes(@reflection)
end
# Build SQL conditions from attributes, qualified by table name.