Class: SchemaCommentsController

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

Constant Summary

Constants inherited from ApplicationController

ApplicationController::ALLOWABLE_CONFIGS

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  respond_to do |format|
    format.json do
      schema_comment = SchemaComment.create(schema_comment_params)

      if schema_comment.errors.any?
        render json: { success: false, errors: schema_comment.errors }, status: :unprocessable_entity
      else
        render json: schema_comment
      end
    end
  end
end

#destroyObject



33
34
35
36
# File 'app/controllers/schema_comments_controller.rb', line 33

def destroy
  @schema_comment.destroy
  redirect_to queries_path
end

#updateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/schema_comments_controller.rb', line 19

def update
  respond_to do |format|
    format.json do
      @schema_comment.update(schema_comment_params)

      if @schema_comment.errors.any?
        render json: { success: false, errors: @schema_comment.errors }, status: :unprocessable_entity
      else
        render json: @schema_comment
      end
    end
  end
end