module JamRuby
  class MusicSessionComment < ActiveRecord::Base
    include HtmlSanitize
    html_sanitize strict: [:comment]

    self.table_name = "music_sessions_comments"

    self.primary_key = 'id'

    default_scope { order('created_at DESC') }

    belongs_to(:music_session,
               :class_name => "JamRuby::MusicSession",
               :foreign_key => "music_session_id")

    belongs_to(:user,
               :class_name => "JamRuby::User",
               :foreign_key => "creator_id")

    validates :comment, length: {maximum: 1000}, no_profanity: true
  end
end