Class: Api::V3::RawController
- Inherits:
-
ApplicationController
- Object
- Api::V2::ApplicationController
- ApplicationController
- Api::V3::RawController
- Defined in:
- app/controllers/api/v3/raw_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#create, #destroy, #index, #show, #update
Instance Method Details
#sql ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/api/v3/raw_controller.rb', line 4 def sql return render json: { error: "Query is required" }, status: 400 if params[:query].nil? result = SafeSqlExecutor.execute_select(params[:query]).to_a render json: result, status: 200 rescue ArgumentError => e render json: { error: e. }, status: 400 rescue ActiveRecord::StatementInvalid => e render json: { error: e. }, status: 400 end |