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

18 lines
535 B
Ruby

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