Class: Adhoq::PreviewsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/adhoq/previews_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

before_action

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/adhoq/previews_controller.rb', line 5

def create
  begin
    query = Adhoq::Query.new(query: params[:query])
    raw_query = query.substitute_query(params[:parameters] || {})
    @result = Adhoq::Executor.new(raw_query).execute
  rescue ActiveRecord::StatementInvalid => @statement_invalid
    render 'statement_invalid', status: :unprocessable_entity
  end
end