0

I want my comments to show at descending order, but adding :order in Post model doesn't work.

class Post < ActiveRecord::Base
    has_many :comments, :order => "created_at DESC"
    validates :title, presence: true,
                      length: { minimum: 5, maximum: 50 }
    validates :body, presence: true,
                      length: { minimum: 20, maximum: 200 }
end

I get an argument error on show action of PostsController. What's the method used to do this?

Nikola Stojaković
  • 2,257
  • 4
  • 27
  • 49

0 Answers0