class ExerciseAnswerComment < ApplicationRecord # belongs_to :exercise_answer belongs_to :user belongs_to :exercise_question belongs_to :exercise_shixun_answer, optional: true belongs_to :exercise_answer, optional: true scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)} validates :comment, length: { maximum: 100, too_long: "不能超过100个字符" } end