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
|
2012-03-04 12:32:39 +00:00
|
|
|
created_at && created_at.strftime("%Y-%m-%dT%H:%M:%S")
|
2012-03-03 17:09:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def as_json(options = {})
|
|
|
|
super({
|
|
|
|
:include => {
|
|
|
|
:user => {
|
2012-03-08 14:00:10 +00:00
|
|
|
:only => [:id, :nickname, :avatar_url]
|
2012-03-03 17:09:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
:methods => [:created]
|
|
|
|
}.merge(options))
|
|
|
|
end
|
|
|
|
|
2012-03-01 23:25:55 +00:00
|
|
|
end
|