Class: Admin::PromotionsController
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
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/admin/promotions_controller.rb', line 24
def create
@promotion = Promotion.new permitted_params
if promotion.save
redirect_to %i[admin promotions], notice: 'Created successfully'
else
flash[:alert] = promotion.errors.full_messages.to_sentence
render :edit
end
end
|
#destroy ⇒ Object
44
45
46
47
48
49
50
|
# File 'app/controllers/admin/promotions_controller.rb', line 44
def destroy
if promotion.destroy
redirect_to %i[admin promotions], notice: 'Deleted successfully'
else
redirect_back fallback_location: back_fallback_location, alert: promotion.errors.full_messages.to_sentence
end
end
|
#edit ⇒ Object
22
|
# File 'app/controllers/admin/promotions_controller.rb', line 22
def edit; end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'app/controllers/admin/promotions_controller.rb', line 9
def index
@grid = Admin::PromotionsGrid.new params[:admin_promotions_grid] do |scope|
scope.page(params[:page])
end
set_meta_tags title: 'Promotions Overview'
etag = CityHash.hash32([self.class.to_s, @grid.assets.cache_key])
return unless stale?(etag: etag)
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/admin/promotions_controller.rb', line 18
def new
@promotion = Promotion.new
end
|
#push_notification ⇒ Object
52
53
54
55
56
57
|
# File 'app/controllers/admin/promotions_controller.rb', line 52
def push_notification
pn = PushNotification.new 'user'
pn.publish_promotion(params.require(:promotion_id))
redirect_back fallback_location: back_fallback_location, notice: 'Push notification will be sent'
end
|
#update ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/admin/promotions_controller.rb', line 34
def update
promotion.attributes = permitted_params
if promotion.save
redirect_to %i[admin promotions], notice: 'Updated successfully'
else
flash[:alert] = promotion.errors.full_messages.to_sentence
render :edit
end
end
|