title: Mongoid Rails 4 sort by asc or desc order created_at
body: <p>I have a rails 4 app using Mongoid.
  I want to do something basic is display the book model I have by descending order according to the field created_at in the index view.
  In the controller books_controller.rb:</p>
  
  <pre><code>def index
    @books = Book.order_by(:created_at.desc)
  end
  </code></pre>
  
  <p>This is not working. I also tried the following 2 that are not working:</p>
  
  <pre><code>@books = Book.find :all, :order =&gt; "created_at DESC"
  
  Book.find(:all, :order =&gt; "created_at DESC").each do |item|
    @books &lt;&lt; item
  end
  </code></pre>
  
  <p>In the view i have something like this:</p>
  
  <pre><code>&lt;% @books.each do |b| %&gt;
    ...
  &lt;% end %&gt;
  </code></pre>
  
  <p>Thank you.</p>