Class: Admin::HhSpecialsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/hh_specials_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



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

def create
  @hh_sp = HhSpecial.new hh_special_params
  if @hh_sp.save
    redirect_to admin_hh_specials_path, notice: 'Add success'
  else
    flash[:error] = @hh_sp.errors.full_messages.to_sentence
    render 'edit'
  end
end

#destroyObject



37
38
39
40
41
42
43
44
# File 'app/controllers/admin/hh_specials_controller.rb', line 37

def destroy
  if @hh_sp.update active: 0
    redirect_to admin_hh_specials_path, notice: 'Data updated'
  else
    flash[:error] = @hh_sp.errors.full_messages.to_sentence
    render 'edit'
  end
end

#editObject



12
# File 'app/controllers/admin/hh_specials_controller.rb', line 12

def edit; end

#indexObject



4
5
6
7
8
9
10
# File 'app/controllers/admin/hh_specials_controller.rb', line 4

def index
  set_meta_tags title: 'HH Special'
  @grid = ::Admin::HhSpecialsGrid.new(params[:admin_hh_specials_grid]) do |scope|
    scope.page(params[:page]).per(50)
  end
  fresh_when @grid.assets.cache_key
end

#newObject



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

def new
  @hh_sp = HhSpecial.new
end

#updateObject



14
15
16
17
18
19
20
21
# File 'app/controllers/admin/hh_specials_controller.rb', line 14

def update
  if @hh_sp.update hh_special_params
    redirect_to admin_hh_specials_path, notice: 'Data updated'
  else
    flash[:error] = @hh_sp.errors.full_messages.to_sentence
    render 'edit'
  end
end