Class: RailsPgExtrasWeb::QueriesController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



5
# File 'app/controllers/rails_pg_extras_web/queries_controller.rb', line 5

def index; end

#runObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/rails_pg_extras_web/queries_controller.rb', line 7

def run
  if @query_name = params[:query_name].presence
    begin
      @result = RailsPGExtras.run_query(query_name: @query_name.to_sym, in_format: :raw)
    rescue ActiveRecord::StatementInvalid => e
      @error = e.message
    end
  else
    redirect_to root_path
  end
end