class method
self.reverse_sql_order
Ruby on Rails 2.3.18
Since v2.2.3 Last seen in v2.3.18 PrivateAvailable in: v2.2.3 v2.3.18
Signature
self.reverse_sql_order(order_query)
No documentation comment.
Parameters
-
order_queryreq
Source
# File activerecord/lib/active_record/base.rb, line 1564
def reverse_sql_order(order_query)
reversed_query = order_query.to_s.split(/,/).each { |s|
if s.match(/\s(asc|ASC)$/)
s.gsub!(/\s(asc|ASC)$/, ' DESC')
elsif s.match(/\s(desc|DESC)$/)
s.gsub!(/\s(desc|DESC)$/, ' ASC')
elsif !s.match(/\s(asc|ASC|desc|DESC)$/)
s.concat(' DESC')
end
}.join(',')
end
Defined in activerecord/lib/active_record/base.rb line 1564
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base