Class: Decidim::Debates::DebatesController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Debates::DebatesController
- Includes:
- Orderable, FilterResource, Flaggable, FormFactory, Paginable
- Defined in:
- app/controllers/decidim/debates/debates_controller.rb
Overview
Exposes the debate resource so users can view them
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 70 def close (:close, :debate, debate:) @form = form(CloseDebateForm).from_params(params) CloseDebate.call(@form) do on(:ok) do |debate| flash[:notice] = I18n.t("debates.close.success", scope: "decidim.debates") redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path end on(:invalid) do flash[:alert] = I18n.t("debates.close.invalid", scope: "decidim.debates") redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path end end end |
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 24 def create :create, :debate @form = form(DebateForm).from_params(params) CreateDebate.call(@form) do on(:ok) do |debate| flash[:notice] = I18n.t("debates.create.success", scope: "decidim.debates") redirect_to Decidim::ResourceLocatorPresenter.new(debate).path end on(:invalid) do flash.now[:alert] = I18n.t("debates.create.invalid", scope: "decidim.debates") render action: "new" end end end |
#edit ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 46 def edit (:edit, :debate, debate:) @form = form(DebateForm).from_model(debate) end |
#new ⇒ Object
18 19 20 21 22 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 18 def new :create, :debate @form = form(DebateForm).instance end |
#show ⇒ Object
42 43 44 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 42 def show raise ActionController::RoutingError, "Not Found" if debate.blank? end |
#update ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/decidim/debates/debates_controller.rb', line 52 def update (:edit, :debate, debate:) @form = form(DebateForm).from_params(params) UpdateDebate.call(@form, debate) do on(:ok) do |debate| flash[:notice] = I18n.t("debates.update.success", scope: "decidim.debates") redirect_to Decidim::ResourceLocatorPresenter.new(debate).path end on(:invalid) do flash.now[:alert] = I18n.t("debates.update.invalid", scope: "decidim.debates") render :edit end end end |