reorder

reorder(*args)
Instance Public methods

Replaces any existing order defined on the relation with the specified order.

1
User.order('email DESC').reorder('id ASC') # generated SQL has 'ORDER BY id ASC'

Subsequent calls to order on the same relation will be appended. For example:

1
User.order('email DESC').reorder('id ASC').order('name ASC')

generates a query with 'ORDER BY id ASC, name ASC'.

doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.