Sha256: a37a5625f6519095eaea59ad53b44922bd6c17ceb556efa47d8c3912376096ed

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

# Score Sheet Tempalte 是评分表模版。
# #subject 是主题。
# #items 是评分项模版。
# #scorings 是评分表。

class Unidom::Score::ScoreSheetTemplate < Unidom::Score::ApplicationRecord

  self.table_name = 'unidom_score_sheet_templates'

  include Unidom::Common::Concerns::ModelExtension

  validates :name,        allow_blank: true, length: { in: 2..columns_hash['name'].limit }
  validates :total_score, presence:    true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }

  belongs_to :subject, polymorphic: true

  has_many :items,    class_name: 'Unidom::Score::ScoreItemTemplate', foreign_key: :sheet_id
  has_many :scorings, class_name: 'Unidom::Score::ScoreSheet',        foreign_key: :template_id

  scope :subject_is, ->(subject) { where subject: subject }

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unidom-score-0.4.1 app/models/unidom/score/score_sheet_template.rb
unidom-score-0.4 app/models/unidom/score/score_sheet_template.rb