Class: Admin::AdvertisementsController
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
#clear_all_compact_restaurant_cache ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/admin/advertisements_controller.rb', line 59
def clear_all_compact_restaurant_cache
Restaurant.active.not_expired.pluck(:id).each do |restaurant_id|
GenerateCompactRestaurantsWorker.perform_async(restaurant_id)
end
flash[:notice] = 'System will clear cache and generating compact restaurat data..'
advertisement = Advertisement.find_by(id: params[:ads_id])
if advertisement.present?
redirect_to edit_admin_advertisement_path advertisement
else
redirect_to new_admin_advertisement_path
end
end
|
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/admin/advertisements_controller.rb', line 23
def create
@advertisement = Advertisement.new(ads_params)
if @advertisement.save
@advertisement.clear_content_cache
flash[:notice] = 'Add success'
redirect_to admin_advertisements_path
else
flash[:error] = @advertisement.errors.full_messages.to_sentence
render 'edit'
end
end
|
#destroy ⇒ Object
51
52
53
54
55
56
57
|
# File 'app/controllers/admin/advertisements_controller.rb', line 51
def destroy
if @advertisement.destroy
redirect_to admin_advertisements_path, notice: 'Delete success'
else
redirect_to admin_advertisements_path, alert: 'Delete failed'
end
end
|
#edit ⇒ Object
36
37
38
|
# File 'app/controllers/admin/advertisements_controller.rb', line 36
def edit
set_data
end
|
#index ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/controllers/admin/advertisements_controller.rb', line 9
def index
set_meta_tags title: 'Advertisements Overview'
@grid = ::Admin::AdvertisementsGrid.new(params[:admin_advertisements_grid]) do |scope|
scope.page(params[:page]).per(20)
end
fresh_when @grid.assets.cache_key
end
|
#new ⇒ Object
19
20
21
|
# File 'app/controllers/admin/advertisements_controller.rb', line 19
def new
@advertisement = Advertisement.new
end
|
#show ⇒ Object
17
|
# File 'app/controllers/admin/advertisements_controller.rb', line 17
def show; end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/admin/advertisements_controller.rb', line 40
def update
if @advertisement.update(ads_params)
@advertisement.clear_content_cache
flash[:notice] = 'Update success'
redirect_to admin_advertisements_path
else
flash[:error] = @advertisement.errors.full_messages.to_sentence
render 'edit'
end
end
|