Sha256: 3459c3f7e15b6f7eac914d4e6dee166d8770707c25ae3683be2ad964abb453d0

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

class SchemaCommentsController < ApplicationController
  respond_to :json
  before_filter :fetch_schema_comment, only: [:update, :destroy]

  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

  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

  def destroy
    @schema_comment.destroy
    redirect_to queries_path
  end

  private

  def fetch_schema_comment
    @schema_comment = SchemaComment.find(params[:id])
  end

  def schema_comment_params
    params.permit(:table, :schema, :column, :target_type, :text).merge(user: current_user)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev app/controllers/schema_comments_controller.rb
aleph_analytics-0.4.8 app/controllers/schema_comments_controller.rb
aleph_analytics-0.4.7 app/controllers/schema_comments_controller.rb
aleph_analytics-0.4.4 app/controllers/schema_comments_controller.rb
aleph_analytics-0.4.2 app/controllers/schema_comments_controller.rb
aleph_analytics-0.4.1 app/controllers/schema_comments_controller.rb
aleph_analytics-0.3.0 app/controllers/schema_comments_controller.rb
aleph_analytics-0.2.0 app/controllers/schema_comments_controller.rb
aleph_analytics-0.1.0 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.6 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.5 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.4 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.3 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.2 app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.1.alpha app/controllers/schema_comments_controller.rb
aleph_analytics-0.0.0.alpha app/controllers/schema_comments_controller.rb