Class: Workarea::Admin::CreatePricingDiscountsController

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



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 12

def create
  @discount.attributes = params[:discount] unless @discount.new_record?

  if @discount.save
    flash[:success] = t('workarea.admin.create_pricing_discounts.flash_messages.saved')
    redirect_to publish_create_pricing_discount_path(@discount, type: params[:type])
  else
    render :rules, status: :unprocessable_entity
  end
end

#destroyObject



48
49
50
51
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 48

def destroy
  @discount.destroy
  redirect_to create_pricing_discounts_path
end

#detailsObject



27
28
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 27

def details
end

#editObject



23
24
25
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 23

def edit
  render :setup
end

#indexObject



8
9
10
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 8

def index
  render :setup
end

#publishObject



33
34
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 33

def publish
end

#rulesObject



30
31
# File 'app/controllers/workarea/admin/create_pricing_discounts_controller.rb', line 30

def rules
end

#save_publishObject



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

def save_publish
  publish = SavePublishing.new(@discount, params)

  if publish.perform
    flash[:success] = t('workarea.admin.create_pricing_discounts.flash_messages.created')
    redirect_to pricing_discount_path(@discount)
  else
    flash[:error] = publish.errors.full_messages
    render :publish
  end
end