Muhammad Faisal Iqbal Muhammad Faisal Iqbal - 2 years ago 51
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download