# app/controllers/concerns/expections_errors.rb
module PpaParticipativoControllersConcern
	extend ActiveSupport::Concern

	included do
		before_action :verifica_se_tem_ppa_partipativo_ativo!, except: [:index, :new, :create]
	end

	def verifica_se_tem_ppa_partipativo_ativo!
		ppa = Ppa::Ppa.find_by(ppa_participativo_ativo: true)

		unless ppa.present? && current_cidadao.present?
			sign_out(current_cidadao)
			redirect_to ppa_participativo_path
		end
	end
end
