Class: IronAdmin::ToolsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IronAdmin::ToolsController
- Defined in:
- app/controllers/iron_admin/tools_controller.rb
Overview
Controller for rendering and executing admin tools.
Supports both legacy bare-method tools and enhanced tools with tool_action declarations, context injection, and authorization.
Instance Method Summary collapse
-
#action_form ⇒ Object
Renders the form for a tool action with form_fields.
- #execute ⇒ Object
- #show ⇒ Object
Instance Method Details
#action_form ⇒ Object
Renders the form for a tool action with form_fields.
33 34 35 36 37 38 39 40 |
# File 'app/controllers/iron_admin/tools_controller.rb', line 33 def action_form @declared_action = @tool_class.find_tool_action(params[:action_name]) return head(:not_found) unless @declared_action&.has_form? return head(:forbidden) unless @declared_action.allowed?(iron_admin_current_user) @form_fields = @declared_action.form_fields @form_url = tool_action_path(@tool_class.tool_name, @declared_action.name) end |
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/iron_admin/tools_controller.rb', line 16 def execute action_name = params[:action_name] declared = @tool_class.find_tool_action(action_name) if declared return head(:forbidden) unless declared.allowed?(iron_admin_current_user) return unless run_tool_action(declared) elsif @tool_class.method_defined?(action_name) run_legacy_action(action_name) else return head(:not_found) end redirect_to tool_path(@tool_class.tool_name) end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/iron_admin/tools_controller.rb', line 11 def show tool_template = "iron_admin/tools/#{@tool_class.tool_name}/show" render tool_template if lookup_context.exists?(tool_template) end |