Govind Patidar
Govind Patidar

Reputation: 1

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

/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.

Upvotes: 0

Views: 48

Answers (1)

spickermann
spickermann

Reputation: 106802

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)

Upvotes: 1

Related Questions