Class: Decidim::DecidimAwesome::EditorImagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::DecidimAwesome::EditorImagesController
- Includes:
- NeedsAwesomeConfig, FormFactory
- Defined in:
- app/controllers/decidim/decidim_awesome/editor_images_controller.rb
Overview
This controller handles image uploads for the Tiptap editor
Instance Method Summary collapse
Methods included from NeedsAwesomeConfig
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/decidim/decidim_awesome/editor_images_controller.rb', line 13 def create (:create, :editor_image, awesome_config:) @form = form(EditorImageForm).from_params(form_values) CreateEditorImage.call(@form) do on(:ok) do |image| url = image.attached_uploader(:file).path url = "#{request.base_url}#{url}" unless url&.start_with?("http") render json: { url:, message: I18n.t("decidim_awesome.editor_images.create.success", scope: "decidim") } end on(:invalid) do || render json: { message: I18n.t("decidim_awesome.editor_images.create.error", scope: "decidim") }, status: :unprocessable_entity end end end |