Sha256: 624565d01acc6355678a8c5eb44c75a1ea57f6dd901e7fe235401ccc68e792f8

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 Bytes

Contents

class Api::ApiController < ActionController::Base
  include Stitches::Deprecation
  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 ||= request.env[Stitches.configuration.env_var_to_hold_api_client]
    # Use this if you want to look up the ApiClient instead of using the one placed into the env
    # @api_client ||= ApiClient.find(request.env[Stitches.configuration.env_var_to_hold_api_client_primary_key])
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stitches-3.7.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.6.1 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.6.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.6.0.RC1 lib/stitches/generator_files/app/controllers/api/api_controller.rb