I want to sort data into descending order in rails app and I used sqlite3 database. So is there any order_by available in rails

43 views Asked by At

/home/dell/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8/lib/active_record/dynamic_matchers.rb:22:in method_missing': undefined method order_by' for User:Class (NoMethodError) Did you mean? order irb(main):015>

I want to sort data into descending order in rails app and I used sqlite3 database. So is there any order_by available in rails.

1

There are 1 answers

2
spickermann On

The method to return database records in a certain order is called order in ActiveRecord.

It can be used like this: User.order(name: :desc)