Class: Workarea::Admin::CatalogProductSwatchesController

Inherits:
Admin::ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/admin/catalog_product_swatches_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/workarea/admin/catalog_product_swatches_controller.rb', line 10

def create
  @swatch = @product.swatches.build(params[:swatch])

  if @swatch.save
    flash[:success] = t('workarea.admin.catalog_product_swatches.flash_messages.saved')
    redirect_to catalog_product_swatches_path(@product)
  else
    render :index, status: :unprocessable_entity
  end
end

#destroyObject



33
34
35
36
37
# File 'app/controllers/workarea/admin/catalog_product_swatches_controller.rb', line 33

def destroy
  @product.swatches.find(params[:id]).destroy
  flash[:success] = t('workarea.admin.catalog_product_swatches.flash_messages.removed')
  redirect_to catalog_product_swatches_path(@product)
end

#indexObject



7
8
# File 'app/controllers/workarea/admin/catalog_product_swatches_controller.rb', line 7

def index
end

#updateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/workarea/admin/catalog_product_swatches_controller.rb', line 21

def update
  @swatch = @product.swatches.find(params[:id])

  if @swatch.update_attributes(params[:swatch])
    flash[:success] = t('workarea.admin.catalog_product_swatches.flash_messages.saved')
    redirect_to catalog_product_swatches_path(@product)
  else
    flash[:error] = t('workarea.admin.catalog_product_swatches.flash_messages.error')
    render :index
  end
end