Files
nairobi/app/models/progress_bar.rb
Senén Rodero Rodríguez da1c5fdb01 Remove unneded before validation callbacks
After globalize gem update there is no need to keep this monkey patch.

More information here [1]

[1] 3075c89b70
2019-06-27 09:19:37 +02:00

24 lines
654 B
Ruby

class ProgressBar < ApplicationRecord
self.inheritance_column = nil
RANGE = 0..100
enum kind: %i[primary secondary]
belongs_to :progressable, polymorphic: true
translates :title, touch: true
include Globalizable
translation_class_delegate :primary?
validates :progressable, presence: true
validates :kind, presence: true,
uniqueness: {
scope: [:progressable_type, :progressable_id],
conditions: -> { primary }
}
validates :percentage, presence: true, inclusion: RANGE, numericality: { only_integer: true }
validates_translation :title, presence: true, unless: :primary?
end