Class: RoundhouseUi::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/roundhouse_ui/application_controller.rb

Constant Summary collapse

AUDIT_VERBS =

Record every state-changing (POST) action. Actions halted by a before_action (e.g. read-only mode) never reach here, so we only log what actually ran.

{
  "purge" => "purged queue", "pause" => "paused queue", "resume" => "resumed queue",
  "snapshot" => "snapshotted queue", "requeue" => "retried", "destroy" => "deleted",
  "bulk" => "bulk action", "enqueue" => "enqueued now", "restore" => "restored snapshot",
  "quiet" => "quieted process", "stop" => "stopped process",
  "create" => "enqueued job", "update" => "edited & re-enqueued",
  "cancel" => "requested cancel"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allow_in_read_only(*actions) ⇒ Object



38
39
40
# File 'app/controllers/roundhouse_ui/application_controller.rb', line 38

def self.allow_in_read_only(*actions)
  self.read_only_exempt_actions = actions.map(&:to_s).freeze
end

.guard_in_read_only(*actions) ⇒ Object



42
43
44
# File 'app/controllers/roundhouse_ui/application_controller.rb', line 42

def self.guard_in_read_only(*actions)
  self.read_only_extra_actions = actions.map(&:to_s).freeze
end

.requires_capability(capability, only:) ⇒ Object



54
55
56
# File 'app/controllers/roundhouse_ui/application_controller.rb', line 54

def self.requires_capability(capability, only:)
  self.capability_gates = capability_gates.merge(capability => Array(only).map(&:to_s)).freeze
end

Instance Method Details

#redirect_to(options = {}, response_options = {}) ⇒ Object

Use 303 See Other after POSTs so Turbo treats form submissions as redirects (and visits the target in place) instead of re-issuing the POST.



76
77
78
79
# File 'app/controllers/roundhouse_ui/application_controller.rb', line 76

def redirect_to(options = {}, response_options = {})
  response_options[:status] ||= :see_other if request.post?
  super
end