diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-04 10:12:40 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-04 10:13:22 -0800 |
commit | d22592a05b299c21e30ec8b38890a178dca863b4 (patch) | |
tree | dee6c232c25ee8d100d11aa3e3c16944200a7d99 /activerecord/lib/active_record/relation/finder_methods.rb | |
parent | f8df37bc019b9537eff33d8b2a57e7b1c379640f (diff) | |
download | rails-d22592a05b299c21e30ec8b38890a178dca863b4.tar.gz rails-d22592a05b299c21e30ec8b38890a178dca863b4.tar.bz2 rails-d22592a05b299c21e30ec8b38890a178dca863b4.zip |
Merge pull request #4282 from edgecase/order_after_reorder
correctly handle order calls after a reorder
Diffstat (limited to 'activerecord/lib/active_record/relation/finder_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 7fe50b93a1..3015b4b40d 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -134,7 +134,7 @@ module ActiveRecord def last(*args) if args.any? if args.first.kind_of?(Integer) || (loaded? && !args.first.kind_of?(Hash)) - if order_values.empty? && reorder_value.nil? + if order_values.empty? order("#{primary_key} DESC").limit(*args).reverse else to_a.last(*args) @@ -249,7 +249,7 @@ module ActiveRecord end def construct_limited_ids_condition(relation) - orders = (relation.reorder_value || relation.order_values).map { |val| val.presence }.compact + orders = relation.order_values.map { |val| val.presence }.compact values = @klass.connection.distinct("#{@klass.connection.quote_table_name table_name}.#{primary_key}", orders) relation = relation.dup |