Reputation: 2667
I'm trying to order the output of a where ActiveRecord query :
result = Class.where('a = ? AND b = ?', params[:a], params[:b])
I tried chaining order
both before and after without succeeding, what am I missing ?
#Not working, the order is not modified compared to previous line
result = Class.where('a = ? AND b = ?', params[:a], params[:b]).order('c DESC')
Upvotes: 2
Views: 44
Reputation: 12818
Try to unscope
the model, something like
result = Class.unscoped.where('a = ? AND b = ?', params[:a], params[:b]).order('c DESC')
Or delete the default scope if it is not used elsewhere
Upvotes: 2