This rule was added in rubocop 1.79. We were inconsistent about it, so we're adding it to get more consistency.
27 lines
745 B
Ruby
27 lines
745 B
Ruby
class ProgressBar < ApplicationRecord
|
|
self.inheritance_column = nil
|
|
RANGE = (0..100)
|
|
|
|
enum :kind, { primary: 0, secondary: 1 }
|
|
|
|
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: { in: ->(*) { RANGE }},
|
|
numericality: { only_integer: true }
|
|
|
|
validates_translation :title, presence: true, unless: :primary?
|
|
end
|