Class: Avo::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Avo::ApplicationController
show all
- Includes:
- ApplicationHelper, UrlHelpers, Pagy::Backend
- 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, #resource_view_path, #resources_path
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg
Instance Method Details
#_current_user ⇒ Object
89
90
91
|
# File 'app/controllers/avo/application_controller.rb', line 89
def _current_user
instance_eval(&Avo.configuration.current_user)
end
|
#check_avo_license ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/avo/application_controller.rb', line 64
def check_avo_license
if on_custom_tool_page
if @license.lacks(:custom_tools) || @license.invalid?
message = "Your license is invalid or doesn't support custom tools."
end
end
if on_dashboards_path
if @license.lacks(:dashboards) || @license.invalid?
message = "Your license is invalid or doesn't support dashboards."
end
end
if message.present?
if Rails.env.development? || Rails.env.test?
@custom_tools_alert_visible = message
elsif @license.lacks_with_trial(:custom_tools)
raise Avo::LicenseInvalidError, message
end
end
end
|
#context ⇒ Object
93
94
95
|
# File 'app/controllers/avo/application_controller.rb', line 93
def context
instance_eval(&Avo.configuration.context)
end
|
#exception_logger(exception) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/avo/application_controller.rb', line 33
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
27
28
29
30
31
|
# File 'app/controllers/avo/application_controller.rb', line 27
def init_app
Avo::App.init request: request, context: context, current_user: _current_user, view_context: view_context, params: params
@license = Avo::App.license
end
|
#render(*args) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/avo/application_controller.rb', line 46
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
if params[:controller] == "avo/dashboards" && params[:action] == "show"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:show).source_location.first.match?(/.*\/app\/controllers\/avo\/dashboards_controller\.rb/)
end
if params[:controller] == "avo/dashboards" && params[:action] == "card"
raise Avo::LicenseVerificationTemperedError, "License verification mechanism tempered with." unless method(:card).source_location.first.match?(/.*\/app\/controllers\/avo\/dashboards_controller\.rb/)
end
super(*args)
end
|
#turbo_frame_request? ⇒ Boolean
This is coming from Turbo::Frames::FrameRequest module. Exposing it as public method
99
100
101
|
# File 'app/controllers/avo/application_controller.rb', line 99
def turbo_frame_request?
super
end
|