Class: Kadmin::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Kadmin::ApplicationController
show all
- Includes:
- Concerns::AuthorizedUser
- Defined in:
- app/controllers/kadmin/application_controller.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#authorize, #authorized_user, #current_user
Class Method Details
.navbar_section ⇒ Object
23
24
25
|
# File 'app/controllers/kadmin/application_controller.rb', line 23
def navbar_section
return @navbar_section ||= self
end
|
.navbar_section=(id) ⇒ Object
19
20
21
|
# File 'app/controllers/kadmin/application_controller.rb', line 19
def navbar_section=(id)
@navbar_section = id.to_s.freeze
end
|
Instance Method Details
#handle_error(error, options = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/kadmin/application_controller.rb', line 49
def handle_error(error, options = {})
options = {
title: error.try(:title) || error.class.name,
message: error.message,
status: :internal_server_error,
error: error
}.merge(options)
render 'kadmin/error', status: options[:status], locals: options
end
|
#handle_unexpected_error(error) ⇒ Object
44
45
46
47
|
# File 'app/controllers/kadmin/application_controller.rb', line 44
def handle_unexpected_error(error)
Rails.logger.error(error)
handle_error(error, title: I18n.t('kadmin.errors.unexpected'), message: I18n.t('kadmin.errors.unexpected_message'))
end
|
#not_found(error) ⇒ Object
40
41
42
|
# File 'app/controllers/kadmin/application_controller.rb', line 40
def not_found(error)
handle_error(error, title: I18n.t('kadmin.errors.not_found'), status: :not_found)
end
|
#params_missing(error) ⇒ Object
36
37
38
|
# File 'app/controllers/kadmin/application_controller.rb', line 36
def params_missing(error)
handle_error(error, title: I18n.t('kadmin.errors.params_missing'), status: :bad_request)
end
|