diff options
author | Daniel Luz <dev@mernen.com> | 2008-12-21 22:38:12 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-21 23:24:06 +0000 |
commit | f7bd0beb67c5d9d50e37aa596605b91e61197fbe (patch) | |
tree | 19cadf3a53bc48920c7f3fc6e5dd9c8f7e10f4fc /activerecord/lib/active_record | |
parent | 389534c38c3baaa63ce5cc2ba3bd169415419167 (diff) | |
download | rails-f7bd0beb67c5d9d50e37aa596605b91e61197fbe.tar.gz rails-f7bd0beb67c5d9d50e37aa596605b91e61197fbe.tar.bz2 rails-f7bd0beb67c5d9d50e37aa596605b91e61197fbe.zip |
Ensure Model#last doesn't affects order for another finders inside the same scope [#1499 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index aa6013583d..9db0366c46 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1494,11 +1494,16 @@ module ActiveRecord #:nodoc: end if scoped?(:find, :order) - scoped_order = reverse_sql_order(scope(:find, :order)) - scoped_methods.select { |s| s[:find].update(:order => scoped_order) } + scope = scope(:find) + original_scoped_order = scope[:order] + scope[:order] = reverse_sql_order(original_scoped_order) end - find_initial(options.merge({ :order => order })) + begin + find_initial(options.merge({ :order => order })) + ensure + scope[:order] = original_scoped_order if original_scoped_order + end end def reverse_sql_order(order_query) |