aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/spawn_methods.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/relation/spawn_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb19
1 files changed, 6 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index d5b13c6100..1577a9b116 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -98,19 +98,12 @@ module ActiveRecord
options.assert_valid_keys(VALID_FIND_OPTIONS)
- relation = relation.joins(options[:joins]).
- where(options[:conditions]).
- select(options[:select]).
- group(options[:group]).
- having(options[:having]).
- order(options[:order]).
- limit(options[:limit]).
- offset(options[:offset]).
- from(options[:from]).
- includes(options[:include])
-
- relation = relation.lock(options[:lock]) if options[:lock].present?
- relation = relation.readonly(options[:readonly]) if options.has_key?(:readonly)
+ [:joins, :select, :group, :having, :order, :limit, :offset, :from, :lock, :readonly].each do |finder|
+ relation = relation.send(finder, options[finder]) if options.has_key?(finder)
+ end
+
+ relation = relation.where(options[:conditions]) if options.has_key?(:conditions)
+ relation = relation.includes(options[:include]) if options.has_key?(:include)
relation
end