Sha256: d7838d3853fbd3999187c6d5121e48596e7f7b8b9d05c0f8f6edbf0bed96d059

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module Workarea
  decorate Storefront::ProductsController, with: :murals_your_way do

    def create_your_own
      model = Catalog::Product.find_by(slug: params[:product_id])
      raise InvalidDisplay unless model.active? || current_user.try(:admin?)

      @product = Storefront::ProductViewModel.wrap(
        model,
        view_model_options
        )
    end   

    def update_image
      model = Catalog::Product.find_by(slug: params[:product_id])
      @product = Storefront::ProductViewModel.wrap(model, view_model_options)
      @image = model.images.build(update_params)
            
      if @image.save
        redirect_to product_create_your_own_path(@product)
      else
        render :index, status: :unprocessable_entity
      end
    end

    private

    def update_params
      params.require(:catalog_product).permit(:image) 
    end 

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-image_decoration-1.0.0.pre app/controllers/workarea/storefront/products_controller.decorator