Class: Avo::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Avo::ApplicationController
show all
- Includes:
- ApplicationHelper, UrlHelpers, Pagy::Backend, Pundit
- Defined in:
- app/controllers/avo/application_controller.rb
Instance Method Summary
collapse
Methods included from UrlHelpers
#edit_resource_path, #new_resource_path, #related_resources_path, #resource_attach_path, #resource_detach_path, #resource_path, #resources_path
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #svg, #turbo_frame_wrap
Instance Method Details
#_current_user ⇒ Object
68
69
70
|
# File 'app/controllers/avo/application_controller.rb', line 68
def _current_user
instance_eval(&Avo.configuration.current_user)
end
|
#check_avo_license ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/avo/application_controller.rb', line 53
def check_avo_license
unless on_root_path || on_resources_path || on_api_path
if @license.lacks(:custom_tools) || @license.invalid?
if Rails.env.development? || Rails.env.test?
@custom_tools_alert_visible = true
elsif @license.lacks_with_trial(:custom_tools)
raise Avo::LicenseInvalidError, "Your license is invalid or doesn't support custom tools."
end
end
end
end
|
#context ⇒ Object
72
73
74
|
# File 'app/controllers/avo/application_controller.rb', line 72
def context
instance_eval(&Avo.configuration.context)
end
|
#exception_logger(exception) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/avo/application_controller.rb', line 30
def exception_logger(exception)
respond_to do |format|
format.html { raise exception }
format.json {
render json: {
errors: exception.respond_to?(:record) && exception.record.present? ? exception.record.errors : [],
message: exception.message,
traces: exception.backtrace
}, status: ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
}
end
end
|
#init_app ⇒ Object
24
25
26
27
28
|
# File 'app/controllers/avo/application_controller.rb', line 24
def init_app
Avo::App.init request: request, context: context, root_path: avo.root_path.delete_suffix("/"), current_user: _current_user, view_context: view_context
@license = Avo::App.license
end
|
#render(*args) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/avo/application_controller.rb', line 43
def render(*args)
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:check_avo_license).source_location.first.match?(/.*\/app\/controllers\/avo\/application_controller\.rb/)
if params[:controller] == "avo/search" && params[:action] == "index"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:index).source_location.first.match?(/.*\/app\/controllers\/avo\/search_controller\.rb/)
end
super(*args)
end
|