In rubocop-rails 2.26.0, support was added for Rails 7 syntax in the Rails/EnumHash rule. We took this opportunity to ensure consistency by converting all enums to hash with integer values. This format minimizes the risk of data consistency issues in the database when adding new values.
14 lines
298 B
Ruby
14 lines
298 B
Ruby
class SDG::Phase < ApplicationRecord
|
|
include Cardable
|
|
enum :kind, { sensitization: 0, planning: 1, monitoring: 2 }
|
|
validates :kind, presence: true, uniqueness: true
|
|
|
|
def self.[](kind)
|
|
find_by!(kind: kind)
|
|
end
|
|
|
|
def title
|
|
self.class.human_attribute_name("kind.#{kind}")
|
|
end
|
|
end
|