Muhammad Faisal Iqbal
Muhammad Faisal Iqbal

Reputation: 1836

Ordering model records in Rails

I am using on console:

User.all(:order => "created_at ASC")

by replacing Client with my Model User from Rubyonrails.org, but its giving me this error:

ArgumentError: wrong number of arguments (1 for 0) 

What's wrong with it?

Upvotes: 1

Views: 84

Answers (1)

Ilya
Ilya

Reputation: 13477

You should use ActiveRecord#order for this goal:

User.order("created_at ASC")

or just:

User.order(:created_at)

in your case.

ActiveRecord#all method not expects any arguments.

Upvotes: 6

Related Questions