Class: Admin::OwnersController
Overview
typed: ignore frozen_string_literal: true
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
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/admin/owners_controller.rb', line 40
def create
@owner = Owner.new params[:owner].permit!
if @owner.valid? && @owner.save
redirect_to admin_owners_path, notice: 'New admin created successfully'
else
render 'new'
end
end
|
#destroy ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/controllers/admin/owners_controller.rb', line 28
def destroy
if @owner.destroy
redirect_to admin_owners_path, notice: "#{@owner.name} deleted successfully"
else
redirect_to admin_owners_path, notice: "Failed to delete #{@owner.name}"
end
end
|
#edit ⇒ Object
13
|
# File 'app/controllers/admin/owners_controller.rb', line 13
def edit; end
|
#index ⇒ Object
5
6
7
8
9
|
# File 'app/controllers/admin/owners_controller.rb', line 5
def index
@owners = Owner.includes(:restaurant).order('id desc').page(params[:page])
etag = CityHash.hash32([self.class.to_s, @owners.cache_key, params])
return unless stale?(etag: etag)
end
|
#new ⇒ Object
36
37
38
|
# File 'app/controllers/admin/owners_controller.rb', line 36
def new
@owner ||= Owner.new
end
|
#search ⇒ Object
50
51
52
53
54
55
|
# File 'app/controllers/admin/owners_controller.rb', line 50
def search
query = params[:owner][:query]
query = "%#{query}%"
@owners = Owner.includes(:restaurant).where('email LIKE ? OR id LIKE ? OR owner_name LIKE ?', query, query, query).page(params[:page])
render 'index'
end
|
#show ⇒ Object
11
|
# File 'app/controllers/admin/owners_controller.rb', line 11
def show; end
|
#update ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/admin/owners_controller.rb', line 15
def update
valid_params = params[:owner].permit!
if valid_params[:password].blank?
valid_params.delete :password
valid_params.delete :password_confirmation
end
if @owner.update_attributes(valid_params)
redirect_to admin_owner_path(@owner.id), notice: 'Owner data updated successfully'
else
render 'edit'
end
end
|