Class: Workarea::Admin::PricingSkusController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/pricing_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



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/workarea/admin/pricing_skus_controller.rb', line 25

def create
  @sku.prices = price_params

  if @sku.save
    flash[:success] =
      t('workarea.admin.pricing_skus.saved', sku: @sku.id)
    redirect_to pricing_sku_path(@sku)
  else
    render :new, status: :unprocessable_entity
  end
end

#editObject



37
38
39
# File 'app/controllers/workarea/admin/pricing_skus_controller.rb', line 37

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

#indexObject



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

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

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

#showObject



21
22
23
# File 'app/controllers/workarea/admin/pricing_skus_controller.rb', line 21

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

#updateObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/workarea/admin/pricing_skus_controller.rb', line 41

def update
  if @sku.update_attributes(sku_params)
    flash[:success] =
      t('workarea.admin.pricing_skus.saved', sku: @sku.id)
    redirect_to pricing_sku_path(@sku)
  else
    @sku = PricingSkuViewModel.new(@sku)
    render :edit, status: :unprocessable_entity
  end
end