Class: RailsPgExtras::Web::QueriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_pg_extras/web/queries_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::ACTIONS, ApplicationController::REQUIRED_EXTENSIONS

Instance Method Summary collapse

Methods inherited from ApplicationController

#validate_credentials!

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/rails_pg_extras/web/queries_controller.rb', line 6

def index
  if params[:query_name].present?
    @query_name = params[:query_name].to_sym.presence_in(@all_queries.keys)
    return unless @query_name

    begin
      @result = RailsPgExtras.run_query(query_name: @query_name.to_sym, in_format: :raw)
    rescue ActiveRecord::StatementInvalid => e
      @error = e.message
    end

    render :show
  end
end