aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-03 03:08:01 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-03 03:08:01 +0530
commitc51347152abc7d8a97fd8df3eecfdbfd07673b68 (patch)
treefaf1ce30c34497be727827faab70ecce62cdd678 /activerecord/lib
parenta9c790e10ffd06294200dbbed4692fbd60424800 (diff)
downloadrails-c51347152abc7d8a97fd8df3eecfdbfd07673b68.tar.gz
rails-c51347152abc7d8a97fd8df3eecfdbfd07673b68.tar.bz2
rails-c51347152abc7d8a97fd8df3eecfdbfd07673b68.zip
Get rid of Model.construct_finder_arel_with_includes. Use construct_finder_arel instead
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb2
-rwxr-xr-xactiverecord/lib/active_record/base.rb21
-rw-r--r--activerecord/lib/active_record/named_scope.rb2
3 files changed, 10 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 1ceb0dbf96..cead614d0f 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -58,7 +58,7 @@ module ActiveRecord
find_scope = construct_scope[:find].slice(:conditions, :order)
with_scope(:find => find_scope) do
- relation = @reflection.klass.send(:construct_finder_arel_with_includes, options)
+ relation = @reflection.klass.send(:construct_finder_arel, options)
case args.first
when :first, :last, :all
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 7cefba2b82..e77cc6e697 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -645,7 +645,7 @@ module ActiveRecord #:nodoc:
options = args.extract_options!
set_readonly_option!(options)
- relation = construct_finder_arel_with_includes(options)
+ relation = construct_finder_arel(options)
case args.first
when :first, :last, :all
@@ -1581,17 +1581,7 @@ module ActiveRecord #:nodoc:
offset(construct_offset(options[:offset], scope)).
from(options[:from])
- lock = (scope && scope[:lock]) || options[:lock]
- relation = relation.lock if lock.present?
-
- relation = relation.readonly if options[:readonly]
-
- relation
- end
-
- def construct_finder_arel_with_includes(options = {})
- relation = construct_finder_arel(options)
- include_associations = merge_includes(scope(:find, :include), options[:include])
+ include_associations = merge_includes(scope && scope[:include], options[:include])
if include_associations.any?
if references_eager_loaded_tables?(options)
@@ -1601,6 +1591,11 @@ module ActiveRecord #:nodoc:
end
end
+ lock = (scope && scope[:lock]) || options[:lock]
+ relation = relation.lock if lock.present?
+
+ relation = relation.readonly if options[:readonly]
+
relation
end
@@ -1722,7 +1717,7 @@ module ActiveRecord #:nodoc:
super unless all_attributes_exists?(attribute_names)
if match.finder?
options = arguments.extract_options!
- relation = options.any? ? construct_finder_arel_with_includes(options) : scoped
+ relation = options.any? ? construct_finder_arel(options) : scoped
relation.send :find_by_attributes, match, attribute_names, *arguments
elsif match.instantiator?
scoped.send :find_or_instantiator_by_attributes, match, attribute_names, *arguments, &block
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index 5959265d5e..f63b249241 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -29,7 +29,7 @@ module ActiveRecord
unless scoped?(:find)
finder_needs_type_condition? ? active_relation.where(type_condition) : active_relation.spawn
else
- construct_finder_arel_with_includes
+ construct_finder_arel
end
end
end