Muhammad Faisal Iqbal Muhammad Faisal Iqbal - 1 year ago 25
Ruby Question

Ordering model records in Rails

I am using on console:

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

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

ArgumentError: wrong number of arguments (1 for 0)

What's wrong with it?


You should use ActiveRecord#order for this goal:

User.order("created_at ASC")

or just:


in your case.

ActiveRecord#all method not expects any arguments.