Class: Admin::SelfCheckinSettingsController
Constant Summary
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary
collapse
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
#append_info_to_payload
#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?
#setup_locale
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#create ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 33
def create
@self_checkin_setting = SelfCheckinSetting.new(permitted_params)
respond_to do |format|
if @self_checkin_setting.valid? && @self_checkin_setting.save
format.html do
redirect_to admin_self_checkin_settings_path
end
format.json do
render json: { success: true, message: 'Self check-in setting created successfully' }
end
else
setup_form
format.html { render :new }
format.json do
render json: {
success: false,
errors: @self_checkin_setting.errors.full_messages,
}
end
end
end
end
|
#destroy ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 67
def destroy
respond_to do |format|
if @self_checkin_setting.destroy
format.html do
redirect_to admin_self_checkin_settings_path, notice: 'Self Check-In destroyed successfully'
end
format.json do
render json: { success: true, message: 'Self Check-In destroyed successfully' }
end
else
format.html do
redirect_back fallback_location: back_fallback_location,
notice: @self_checkin_setting.errors.full_messages.to_sentence
end
format.json do
render json: {
success: false,
errors: @self_checkin_setting.errors.full_messages,
}, status: :unprocessable_entity
end
end
end
end
|
#edit ⇒ Object
62
63
64
65
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 62
def edit
@self_checkin_setting.self_checkin_restaurants.build
setup_form
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 5
def index
@self_checkin_settings = SelfCheckinSetting.order(id: :desc).
page(params[:page] || 1).
per(params[:per_page] || 50)
respond_to do |format|
format.html do
set_meta_tags title: 'Self Check-In Setting'
render
end
format.json do
render json: @self_checkin_settings,
meta: {
total_count: SelfCheckinSetting.count,
},
each_serializer: SelfCheckinSettingSerializer,
adapter: :json
end
end
end
|
#new ⇒ Object
27
28
29
30
31
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 27
def new
@self_checkin_setting = SelfCheckinSetting.new
@self_checkin_setting.self_checkin_restaurants.build
setup_form
end
|
#show ⇒ Object
58
59
60
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 58
def show
redirect_to admin_self_checkin_settings_path
end
|
#update ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'app/controllers/admin/self_checkin_settings_controller.rb', line 93
def update
respond_to do |format|
if permitted_params[:self_checkin_restaurants_attributes]
@self_checkin_restaurant_ids = @self_checkin_setting.self_checkin_restaurants.pluck(:id)
end
if @self_checkin_setting.update(permitted_params)
if @self_checkin_restaurant_ids.present?
@self_checkin_setting.self_checkin_restaurants.
where(id: @self_checkin_restaurant_ids).destroy_all
end
format.html do
redirect_to admin_self_checkin_setting_path(@self_checkin_setting.id),
notice: 'Self Check-In data updated successfully'
end
format.json do
render json: { success: true, message: 'Self Check-In data updated successfully' }
end
else
format.html do
flash[:alert] = @self_checkin_setting.errors.full_messages.to_sentence
setup_form
render :edit
end
format.json do
render json: {
success: false,
errors: @self_checkin_setting.errors.full_messages,
}
end
end
end
end
|