demarches-normaliennes/app/models/concerns/domain_migratable_concern.rb

21 lines
566 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module DomainMigratableConcern
extend ActiveSupport::Concern
included do
enum preferred_domain: { demarches_gouv_fr: 0, demarches_simplifiees_fr: 1 }, _prefix: true
validates :preferred_domain, inclusion: { in: User.preferred_domains.keys, allow_nil: true }
def update_preferred_domain(host)
case host
when ApplicationHelper::APP_HOST
preferred_domain_demarches_gouv_fr!
when ApplicationHelper::APP_HOST_LEGACY
preferred_domain_demarches_simplifiees_fr!
end
end
end
end