diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-01 11:29:20 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-01 11:29:20 -0700 |
commit | 90248d2953789f8631480c767ebf3accdbda6a7a (patch) | |
tree | ec6d08695674e4d784ef88c86022cacda47a92fd /activerecord/lib/active_record | |
parent | 7a7a3bcf02976b2dcfb262c781e68da3183d16e8 (diff) | |
parent | 0df27c98d982ec87d2fb48cfda82694eb267993e (diff) | |
download | rails-90248d2953789f8631480c767ebf3accdbda6a7a.tar.gz rails-90248d2953789f8631480c767ebf3accdbda6a7a.tar.bz2 rails-90248d2953789f8631480c767ebf3accdbda6a7a.zip |
Merge pull request #2775 from jaw6/fix/reverse
Fixes bug in ActiveRecord::QueryMethods, #1697
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 7eda9ad8e8..355540782f 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -305,10 +305,8 @@ module ActiveRecord when Arel::Nodes::Ordering o.reverse when String, Symbol - o.to_s.split(',').collect do |s| - s.strip! - s.gsub!(/\sasc\Z/i, ' DESC') || s.gsub!(/\sdesc\Z/i, ' ASC') || s.concat(' DESC') - end + s = o.to_s.gsub(/\s((desc)|(asc))\s*(,|\Z)/i) { |m| " #{$2 ? 'ASC' : 'DESC'}#{$4}" } + s.match(/\s(de|a)sc\Z/i) ? s : s.concat(" DESC") else o end |