aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/named_scope.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-27 13:15:00 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-27 13:17:29 +0530
commit8829d6ecc6b3e1a36a41decaf8237f6024be2c06 (patch)
tree0b59ebc1eca40ac2fa480a8412a6c63016141cce /activerecord/lib/active_record/named_scope.rb
parent51d84eff126392e3a19a7e1bf293d1f1eee21623 (diff)
downloadrails-8829d6ecc6b3e1a36a41decaf8237f6024be2c06.tar.gz
rails-8829d6ecc6b3e1a36a41decaf8237f6024be2c06.tar.bz2
rails-8829d6ecc6b3e1a36a41decaf8237f6024be2c06.zip
Make Model.find_by_* and Model.find_all_by_* use relations and remove dynamic method caching
Diffstat (limited to 'activerecord/lib/active_record/named_scope.rb')
-rw-r--r--activerecord/lib/active_record/named_scope.rb18
1 files changed, 3 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index 96d361093f..a6336e762a 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -26,23 +26,11 @@ module ActiveRecord
if options.present?
Scope.new(self, options, &block)
else
- if !scoped?(:find)
- relation = arel_table
- relation = relation.where(type_condition) if finder_needs_type_condition?
+ unless scoped?(:find)
+ finder_needs_type_condition? ? arel_table.where(type_condition) : arel_table
else
- relation = construct_finder_arel
- include_associations = scope(:find, :include)
-
- if include_associations.present?
- if references_eager_loaded_tables?(options)
- relation.eager_load(include_associations)
- else
- relation.preload(include_associations)
- end
- end
+ construct_finder_arel_with_includes
end
-
- relation
end
end