class ColumnsController

Public Instance Methods

create() click to toggle source

POST /columns

# File natural-backend/app/controllers/columns_controller.rb, line 17
def create
  @column = current_user.columns.build(column_params)

  if @column.save
    render json: @column, status: :created, location: @column
  else
    render json: @column.errors, status: :unprocessable_entity
  end
end
destroy() click to toggle source

DELETE /columns/1

# File natural-backend/app/controllers/columns_controller.rb, line 37
def destroy
  @column.destroy
end
index() click to toggle source

GET /columns

# File natural-backend/app/controllers/columns_controller.rb, line 5
def index
  @columns = current_user.columns.all

  render json: @columns
end
show() click to toggle source

GET /columns/1

# File natural-backend/app/controllers/columns_controller.rb, line 12
def show
  render json: @column
end
update() click to toggle source

PATCH/PUT /columns/1

# File natural-backend/app/controllers/columns_controller.rb, line 28
def update
  if @column.update(column_params)
    render json: @column
  else
    render json: @column.errors, status: :unprocessable_entity
  end
end

Private Instance Methods

column_params() click to toggle source

Only allow a trusted parameter “white list” through.

# File natural-backend/app/controllers/columns_controller.rb, line 48
def column_params
  ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [:table, :name, :type])
end
set_column() click to toggle source

Use callbacks to share common setup or constraints between actions.

# File natural-backend/app/controllers/columns_controller.rb, line 43
def set_column
  @column = current_user.columns.find(params[:id])
end