Class: Decidim::Notify::ChaptersController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Notify::ChaptersController
- Includes:
- Broadcasts, NeedsAjaxRescue, FormFactory
- Defined in:
- app/controllers/decidim/notify/chapters_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#destroy ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/notify/chapters_controller.rb', line 26 def destroy :destroy, :chapter DeleteChapter.call(params[:id]) do on(:ok) do broadcast_destroy_chapter params[:id] render json: { message: "✔" } end on(:invalid) do || render json: { message: t("destroy.error", scope: "decidim.notify.chapter", message: ) }, status: :unprocessable_entity end end end |
#update ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/decidim/notify/chapters_controller.rb', line 10 def update :create, :chapter @form = form(ChapterForm).from_params(params) UpdateChapter.call(@form) do on(:ok) do |chapter, _old_title| broadcast_update_chapter chapter render json: { message: "✔" } end on(:invalid) do || render json: { message: t("update.error", scope: "decidim.notify.chapter", message: ) }, status: :unprocessable_entity end end end |