demarches-normaliennes/app/models/procedure_path.rb
2018-08-14 16:30:43 +02:00

19 lines
545 B
Ruby

class ProcedurePath < ApplicationRecord
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, presence: true, allow_blank: false, allow_nil: false
validates :administrateur_id, presence: true, allow_blank: false, allow_nil: false
validates :procedure_id, presence: true, allow_blank: false, allow_nil: false
belongs_to :procedure
belongs_to :administrateur
def hide!
destroy!
end
def publish!(new_procedure)
if procedure&.publiee?
procedure.archive!
end
update!(procedure: new_procedure)
end
end