Sha256: 6138716068426123d882687c7f98db3fc88f78302f5b64ce0df3daaf03665579

Contents?: true

Size: 732 Bytes

Versions: 7

Compression:

Stored size: 732 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 ||= 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

7 entries across 7 versions & 1 rubygems

Version Path
stitches-3.5.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.4.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.3.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.2.3 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.2.2 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.2.1 lib/stitches/generator_files/app/controllers/api/api_controller.rb
stitches-3.2.0 lib/stitches/generator_files/app/controllers/api/api_controller.rb