Class: SqlMonitor::ExplainSqlController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/sql_monitor/explain_sql_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



12
13
14
15
16
17
18
19
# File 'app/controllers/sql_monitor/explain_sql_controller.rb', line 12

def index
  return not_found if Rails.env.production?

  data = ActiveRecord::Base.connection.execute("EXPLAIN #{params[:sql]}").first
  render json: {
    result: data.to_json
  }
end

#not_foundObject



6
7
8
9
10
# File 'app/controllers/sql_monitor/explain_sql_controller.rb', line 6

def not_found
  respond_to do |format|
    format.any  { head :not_found }
  end
end