Sha256: b7adea3ad195e992040e85fc40f10751e5417a4ebce34d240cd056d4c7e7d494

Contents?: true

Size: 820 Bytes

Versions: 12

Compression:

Stored size: 820 Bytes

Contents

module Adminpanel
  module GalleryActions
    extend ActiveSupport::Concern

    def add_to_gallery
      image_class = params[:model].camelize.constantize
      image = image_class.new(file: params[:file], model_type: params[:parent_object_class])
      image.model_id = params[:resource_id] if params[:resource_id]

      if image.save
        response = {
          class: image_class.to_controller_name,
          id: image.id,
          image_url: image.file_url(:thumb)
        }
        respond_to do |f|
          f.json{ render status: :ok, json: response.to_json }
        end
      end
    end

    def remove_image
      @image = params[:model].constantize.find(params[:id])
      @image.destroy

      respond_to do |f|
        f.json{ render status: :ok, json: @image.to_json }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
adminpanel-3.6.1 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.6.0 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.5.1 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.5.0 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.7 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.6 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.5 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.4 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.3 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.2 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.1 app/controllers/concerns/adminpanel/gallery_actions.rb
adminpanel-3.4.0 app/controllers/concerns/adminpanel/gallery_actions.rb