Class: Decidim::EditorImagesController

Inherits:
ApplicationController show all
Includes:
FormFactory
Defined in:
decidim-core/app/controllers/decidim/editor_images_controller.rb

Instance Method Summary collapse

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'decidim-core/app/controllers/decidim/editor_images_controller.rb', line 10

def create
  enforce_permission_to :create, :editor_image

  @form = form(EditorImageForm).from_params(form_values)

  CreateEditorImage.call(@form) do
    on(:ok) do |image|
      render json: { url: image.attached_uploader(:file).path, message: I18n.t("success", scope: "decidim.editor_images.create") }
    end

    on(:invalid) do |_message|
      render json: { message: I18n.t("error", scope: "decidim.editor_images.create") }, status: :unprocessable_entity
    end
  end
end