Sha256: 3d0a18cdfdadd25b0ead72ff8b418495dddb407227a9a67d0ebb193509c80b0c

Contents?: true

Size: 973 Bytes

Versions: 85

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

module Spree
  module Admin
    class ImagesController < ResourceController
      before_action :load_data
      create.before :set_viewable
      update.before :set_viewable

      private

      def location_after_destroy
        admin_product_images_url(@product)
      end

      def location_after_save
        admin_product_images_url(@product)
      end

      def load_data
        @product = Spree::Product.friendly.find(params[:product_id])
        @variants = @product.variants.collect do |variant|
          [variant.sku_and_options_text, variant.id]
        end
        @variants.insert(0, [t('spree.all'), @product.master.id])
      rescue ActiveRecord::RecordNotFound
        resource_not_found(flash_class: Spree::Product, redirect_url: admin_products_path)
      end

      def set_viewable
        @image.viewable_type = 'Spree::Variant'
        @image.viewable_id = params[:image][:viewable_id]
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
solidus_backend-4.2.0 app/controllers/spree/admin/images_controller.rb
solidus_backend-4.1.1 app/controllers/spree/admin/images_controller.rb
solidus_backend-4.0.2 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.4.4 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.3.4 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.2.9 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.2.8 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.3.3 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.4.3 app/controllers/spree/admin/images_controller.rb
solidus_backend-4.0.1 app/controllers/spree/admin/images_controller.rb
solidus_backend-4.1.0 app/controllers/spree/admin/images_controller.rb
solidus_backend-4.0.0 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.4.2 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.2.7 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.3.2 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.4.1 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.4.0 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.3.1 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.2.6 app/controllers/spree/admin/images_controller.rb
solidus_backend-3.1.9 app/controllers/spree/admin/images_controller.rb