Hello, i have the following models in my application:
class Message < ActiveRecord::Base
has_many :comments, :as => :commentable, :dependent => :destroy,
:order => ‘created_at ASC’
end
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
I need “commented” named scope, which do the follownig thing:
Message.commented -> returns all messages where comments is > 0.
How i can do this?