You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/app/models/comment.rb

28 lines
522 B
Ruby

class Comment < ActiveRecord::Base
validates :body, :presence => true
validates :asciicast_id, :presence => true
validates :user_id, :presence => true
belongs_to :user
belongs_to :asciicast
attr_accessible :body
def created
created_at && created_at.strftime("%Y-%m-%dT%H:%M:%S")
end
def as_json(options = {})
super({
:include => {
:user => {
:only => [ :id, :nickname, :avatar_url ]
}
},
:methods => [:created]
}.merge(options))
end
end