Sha256: 4aaebbfc04f80a0a378de026e87ee8d549fbde85f3d00208eb91541ca413670f

Contents?: true

Size: 552 Bytes

Versions: 2

Compression:

Stored size: 552 Bytes

Contents

class Api::ApiController < ActionController::Base
  rescue_from ActiveRecord::RecordNotFound do |exception|
    respond_to do |type|
      type.json { render json: { errors: Stitches::Errors.new([ Stitches::Error.new(code: "not_found", message: exception.message) ]) }, status: 404 }
      type.all  { render :nothing => true, :status => 404 }
    end
  end

  def current_user
    api_client
  end

protected

  def api_client
    @api_client ||= ::ApiClient.find(request.env[Stitches.configuration.env_var_to_hold_api_client_primary_key])
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stitches-3.1.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.0.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb