After globalize gem update there is no need to keep this monkey patch.
More information here [1]
[1] 3075c89b70
24 lines
654 B
Ruby
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
|