asciinema.org/app/models/comment.rb

28 lines
478 B
Ruby
Raw Normal View History

2012-03-01 23:25:55 +00:00
class Comment < ActiveRecord::Base
validates :body, :presence => true
validates :asciicast_id, :presence => true
validates :user_id, :presence => true
belongs_to :user
belongs_to :asciicast
2012-03-03 12:09:04 +00:00
attr_accessible :body
2012-03-03 17:09:03 +00:00
def created
created_at.to_s
end
def as_json(options = {})
super({
:include => {
:user => {
:only => [ :nickname, :avatar_url ]
}
},
:methods => [:created]
}.merge(options))
end
2012-03-01 23:25:55 +00:00
end