Class: RailsPgExtras::Web::ApplicationController

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

Direct Known Subclasses

ActionsController, QueriesController

Constant Summary collapse

REQUIRED_EXTENSIONS =
{
  pg_stat_statements: %i[calls outliers pg_stat_statements_reset],
  pg_buffercache: %i[buffercache_stats buffercache_usage],
  sslinfo: %i[ssl_used],
}
ACTIONS =
%i[kill_all pg_stat_statements_reset add_extensions]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_passwordObject



10
11
12
# File 'app/controllers/rails_pg_extras/web/application_controller.rb', line 10

def self.get_password
  Rails.application.try(:credentials).try(:pg_extras).try(:password) || ENV["RAILS_PG_EXTRAS_PASSWORD"]
end

.get_userObject



6
7
8
# File 'app/controllers/rails_pg_extras/web/application_controller.rb', line 6

def self.get_user
  Rails.application.try(:credentials).try(:pg_extras).try(:user) || ENV["RAILS_PG_EXTRAS_USER"]
end

Instance Method Details

#validate_credentials!Object



29
30
31
32
33
# File 'app/controllers/rails_pg_extras/web/application_controller.rb', line 29

def validate_credentials!
  if (self.class.get_user.blank? || self.class.get_password.blank?) && RailsPgExtras.configuration.public_dashboard != true
    raise "Missing credentials for rails-pg-extras dashboard! If you want to enable public dashboard please set RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true"
  end
end