Class: PgInsights::QueriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PgInsights::QueriesController
- Defined in:
- app/controllers/pg_insights/queries_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /pg_insights/queries.
-
#destroy ⇒ Object
DELETE /pg_insights/queries/:id.
-
#update ⇒ Object
PATCH/PUT /pg_insights/queries/:id.
Instance Method Details
#create ⇒ Object
POST /pg_insights/queries
10 11 12 13 14 15 16 17 |
# File 'app/controllers/pg_insights/queries_controller.rb', line 10 def create @query = PgInsights::Query.new(query_params) if @query.save render json: { success: true, query: @query.as_json(only: [ :id, :name, :sql, :description, :category ]) }, status: :created else render json: { success: false, errors: @query.errors. }, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /pg_insights/queries/:id
29 30 31 32 |
# File 'app/controllers/pg_insights/queries_controller.rb', line 29 def destroy @query.destroy head :no_content end |
#update ⇒ Object
PATCH/PUT /pg_insights/queries/:id
20 21 22 23 24 25 26 |
# File 'app/controllers/pg_insights/queries_controller.rb', line 20 def update if @query.update(query_params) render json: { success: true, query: @query.as_json(only: [ :id, :name, :sql, :description, :category ]) } else render json: { success: false, errors: @query.errors. }, status: :unprocessable_entity end end |