class PollAnswer < ApplicationRecord
  # default_scope :order => 'answer_position'
  # include Redmine::SafeAttributes

  belongs_to :poll_question
  has_many :poll_votes, :dependent => :delete_all

  scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)}  #根据传入的参数查找问题
  scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)}  #根据传入的参数查找问题

  validates :answer_text, length: { maximum: 500, too_long: "不能超过500个字符" }

end