Clear ORM
Search…
Ordering & Group by
Ordering of the collection can be made by using order_by method, while Group by is done via group_by :
1
User.query.order_by(last_name: "ASC", first_name: "ASC").each do |usr|
2
puts "#{usr.first_name} #{usr.last_name}"
3
end
Copied!
You can clear the current ordering by using the chainable method clear_order_bys
Last modified 2yr ago
Copy link