Class: Admin::VoucherIntrosController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/voucher_intros_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/admin/voucher_intros_controller.rb', line 16

def create
  @voucher_intro = Vouchers::Intro.new permitted_params
  if voucher_intro.valid? && voucher_intro.save
    redirect_to admin_voucher_intros_path,
                notice: 'Voucher Intro created successfully'
  else
    flash[:alert] = voucher_intro.errors.full_messages.to_sentence
    render :new
  end
end

#destroyObject



42
43
44
45
46
47
48
49
# File 'app/controllers/admin/voucher_intros_controller.rb', line 42

def destroy
  if voucher_intro.destroy
    flash[:notice] = "#{voucher_intro.section_type} deleted successfully"
  else
    flash[:alert] = voucher_intro.errors.full_messages.to_sentence
  end
  redirect_back fallback_location: back_fallback_location
end

#editObject



29
# File 'app/controllers/admin/voucher_intros_controller.rb', line 29

def edit; end

#indexObject



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

def index
  @voucher_intros = Vouchers::Intro.includes(:translations)
end

#newObject



12
13
14
# File 'app/controllers/admin/voucher_intros_controller.rb', line 12

def new
  @voucher_intro = Vouchers::Intro.new
end

#showObject



27
# File 'app/controllers/admin/voucher_intros_controller.rb', line 27

def show; end

#updateObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/admin/voucher_intros_controller.rb', line 31

def update
  voucher_intro.attributes = permitted_params
  if voucher_intro.valid? && voucher_intro.save
    redirect_to admin_voucher_intros_path,
                notice: 'Voucher Intro updated successfully'
  else
    flash[:alert] = voucher_intro.errors.full_messages.to_sentence
    render :edit
  end
end