Method: AWS::Record::Model::Scope#order
- Defined in:
- lib/aws/record/model/scope.rb
#order(attribute_name, order = :asc) ⇒ Object
Specifies how to sort records returned.
# enumerate books, starting with the most recently published ones
Book.order(:published_at, :desc).each do |book|
# ...
end
Only one order may be applied. If order is specified more than once the last one in the chain takes precedence:
# books returned by this scope will be ordered by :published_at
# and not :author.
Book.where(:read => false).order(:author).order(:published_at)
132 133 134 |
# File 'lib/aws/record/model/scope.rb', line 132 def order attribute_name, order = :asc _with(:order => [attribute_name, order]) end |