Sha256: 90164ff1586395461cd4564cc4a3090cf8eac10fd5733065838960b90725137f

Contents?: true

Size: 770 Bytes

Versions: 6

Compression:

Stored size: 770 Bytes

Contents

module PgBouncerHero
  class ApplicationController < ActionController::Base
    layout "pg_bouncer_hero/application"

    protect_from_forgery

    http_basic_authenticate_with name: ENV["PGBOUNCERHERO_USERNAME"], password: ENV["PGBOUNCERHERO_PASSWORD"] if ENV["PGBOUNCERHERO_PASSWORD"]

    if respond_to?(:before_action)
      before_action :set_database
    else
      before_filter :set_database
    end

    protected

    def set_database
      @groups = PgBouncerHero.groups
      if params[:group] && params[:database]
        @database = PgBouncerHero.groups[params[:group]].databases.find { |db| db.id.to_s == params[:database].to_s }
      else
        @group = @groups.first
        @database = @groups.first.last.databases.first
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pgbouncerhero-2.0.0 app/controllers/pg_bouncer_hero/application_controller.rb
pgbouncerhero-1.0.3 app/controllers/pg_bouncer_hero/application_controller.rb
pgbouncerhero-1.0.1 app/controllers/pg_bouncer_hero/application_controller.rb
pgbouncerhero-1.0.0 app/controllers/pg_bouncer_hero/application_controller.rb
pgbouncerhero-0.1.1 app/controllers/pg_bouncer_hero/application_controller.rb
pgbouncerhero-0.1.0 app/controllers/pg_bouncer_hero/application_controller.rb