Class: Admin::WidgetsController
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
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/admin/widgets_controller.rb', line 18
def create
@widget = Widget.new(widget_params)
if @widget.save
redirect_to([:admin, @widget], notice: 'Widget created successfully')
else
flash[:alert] = @widget.errors.full_messages.to_sentence
render :new
end
end
|
#destroy ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'app/controllers/admin/widgets_controller.rb', line 47
def destroy
@widget = Widget.find(params.require(:id))
if @widget.destroy
redirect_to(admin_widgets_path, notice: 'Widget deleted successfully')
else
redirect_back fallback_location: back_fallback_location, alert: @widget.errors.full_messages.to_sentence
end
end
|
#edit ⇒ Object
28
29
30
31
|
# File 'app/controllers/admin/widgets_controller.rb', line 28
def edit
@widget = Widget.find(params.require(:id))
@widget.translations.build
end
|
#index ⇒ Object
5
6
7
8
9
10
11
|
# File 'app/controllers/admin/widgets_controller.rb', line 5
def index
@grid = WidgetsGrid.new(params[:widgets_grid]) do |scope|
scope.page(params[:page])
end
etag = CityHash.hash32([self.class.to_s, @grid.assets.cache_key])
return unless stale?(etag: etag)
end
|
#new ⇒ Object
13
14
15
16
|
# File 'app/controllers/admin/widgets_controller.rb', line 13
def new
@widget ||= Widget.new
@widget.translations.build
end
|
#show ⇒ Object
33
34
35
|
# File 'app/controllers/admin/widgets_controller.rb', line 33
def show
@widget = Widget.find(params.require(:id))
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/admin/widgets_controller.rb', line 37
def update
@widget = Widget.find(params.require(:id))
if @widget.update_attributes(widget_params)
redirect_to([:admin, @widget], notice: 'Widget updated successfully')
else
flash[:alert] = @widget.errors.full_messages.to_sentence
render :edit
end
end
|