aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/named_scope.rb
diff options
context:
space:
mode:
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