diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-20 03:35:25 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-20 03:35:25 +0530 |
commit | 52ec4311f5bf8b596612f297da0b3be8e284b038 (patch) | |
tree | b4caab48841d03a33fe624b3ffd27248b67eca5e /activerecord/lib/active_record/relation/spawn_methods.rb | |
parent | 74e3539cda914bf3cb380e8486d316c275a5f0cf (diff) | |
download | rails-52ec4311f5bf8b596612f297da0b3be8e284b038.tar.gz rails-52ec4311f5bf8b596612f297da0b3be8e284b038.tar.bz2 rails-52ec4311f5bf8b596612f297da0b3be8e284b038.zip |
Delegate all finders to Relation
Diffstat (limited to 'activerecord/lib/active_record/relation/spawn_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 19 |
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 |