Sha256: 6f55e0c56812ca22aa06c11deea5a6c06e9b6de569132b1631b7394a73c8d216
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# Score Sheet 是评分表。 # #score_sheet_template 是评分表模版。 # #scorer 是评分者。 # #score_keeper 是得分者。 class Unidom::Score::ScoreSheet < Unidom::Score::ApplicationRecord self.table_name = 'unidom_score_sheets' include Unidom::Common::Concerns::ModelExtension validates :name, allow_blank: true, length: { in: 2..columns_hash['name'].limit } validates :score, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 } belongs_to :template, class_name: 'Unidom::Score::ScoreSheetTemplate', foreign_key: :score_sheet_template_id belongs_to :scorer, polymorphic: true belongs_to :score_keeper, polymorphic: true def self.score!(scorer: nil, score_keeper: nil, template: nil, name: template.try(:name), score: 0, scored_on: Date.current, opened_at: Time.now, description: nil, instruction: nil) create! scorer: scorer, score_keeper: score_keeper, template: template, name: name, score: score, scored_on: scored_on, opened_at: opened_at, description: description, instruction: instruction end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-score-0.1 | app/models/unidom/score/score_sheet.rb |