Class: Decidim::Demographics::DemographicsController

Inherits:
ApplicationController show all
Includes:
Forms::Concerns::HasQuestionnaire, UserProfile
Defined in:
app/controllers/decidim/demographics/demographics_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#destroyObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/demographics/demographics_controller.rb', line 20

def destroy
  DeleteDemographicData.call(questionnaire, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("destroy.success", scope: "decidim.demographics")
      redirect_to demographics_engine.demographics_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("destroy.error", scope: "decidim.demographics")
      redirect_to demographics_engine.demographics_path
    end
  end
end

#showObject



12
13
14
15
16
17
18
# File 'app/controllers/decidim/demographics/demographics_controller.rb', line 12

def show
  @form = form(Decidim::Forms::QuestionnaireForm).from_model(questionnaire)
  @form.add_responses!(questionnaire:, session_token:, ip_hash:)
  @form.allow_editing_responses = true

  render template:
end

#templateObject



34
35
36
# File 'app/controllers/decidim/demographics/demographics_controller.rb', line 34

def template
  "decidim/demographics/demographics/show"
end