demarches-normaliennes/app/models/procedure_path.rb

20 lines
545 B
Ruby
Raw Normal View History

2018-03-06 13:44:29 +01:00
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
2018-08-14 13:54:39 +02:00
def hide!
destroy!
end
def publish!(new_procedure)
2018-08-14 13:54:39 +02:00
if procedure&.publiee?
procedure.archive!
end
2018-08-14 13:54:39 +02:00
update!(procedure: new_procedure)
end
2017-04-04 15:27:04 +02:00
end