Class: Workarea::Admin::InventorySkusController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/inventory_skus_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/workarea/admin/inventory_skus_controller.rb', line 24

def create
  if @sku.save
    flash[:success] =
      t('workarea.admin.inventory_skus.flash_messages.created', id: @sku.id)
    redirect_to inventory_sku_path(@sku)
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



49
50
51
52
53
54
# File 'app/controllers/workarea/admin/inventory_skus_controller.rb', line 49

def destroy
  @sku.destroy
  flash[:success] =
    t('workarea.admin.inventory_skus.flash_messages.removed', id: @sku.id)
  redirect_to inventory_skus_path
end

#editObject



34
35
36
# File 'app/controllers/workarea/admin/inventory_skus_controller.rb', line 34

def edit
  @sku = InventorySkuViewModel.new(@sku)
end

#indexObject



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

def index
  search_params = if product
                    view_model_options.merge(q: product.skus.join(' '))
                  else
                    view_model_options
                  end

  search = Search::AdminInventorySkus.new(search_params)
  @search = SearchViewModel.new(search, search_params)
end

#showObject



20
21
22
# File 'app/controllers/workarea/admin/inventory_skus_controller.rb', line 20

def show
  @sku = InventorySkuViewModel.new(@sku)
end

#updateObject



38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/workarea/admin/inventory_skus_controller.rb', line 38

def update
  if @sku.update_attributes(params[:sku])
    flash[:success] =
      t('workarea.admin.inventory_skus.flash_messages.saved', id: @sku.id)
    redirect_to inventory_sku_path(@sku)
  else
    @sku = InventorySkuViewModel.new(@sku)
    render :edit, status: :unprocessable_entity
  end
end