I'm doing the following query...
Status.where(:status => params[:cat_id])
but I want to order the results by the created_at column. I've tried everything logical like
Status.where(:status => params[:cat_id]), :order => "created_at DESC"
and
Status.where(:status => params[:cat_id], :order => "created_at DESC")
but nothing seems to work.
What's the best way to order results that you're getting from a where query?
Any help is much appreciated, thanks!
Status.where(:status => params[:cat_id]).order("created_at DESC")
You might want to give a look at the ActiveRecord API documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With