123456789_123456789_123456789_123456789_123456789_

Class: Rails::Application::Configuration

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Rails::Engine::Configuration
Defined in: railties/lib/rails/application/configuration.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Rails::Engine::Configuration - Inherited

#generators

Holds generators configuration:

#paths

::Rails::Railtie::Configuration - Inherited

#after_initialize

Last configurable block to run.

#app_generators

This allows you to modify application's generators from Railties.

#app_middleware

This allows you to modify the application's middlewares from Engines.

#before_configuration

First configurable block to run.

#before_eager_load

Third configurable block to run.

#before_initialize

Second configurable block to run.

#eager_load_namespaces

All namespaces that are eager loaded.

#respond_to?,
#to_prepare

Defines generic callbacks to run before #after_initialize.

#to_prepare_blocks

::Array of callbacks defined by #to_prepare.

#watchable_dirs

Add directories that should be watched for change.

#watchable_files

Add files that should be watched for change.

Constructor Details

.newConfiguration

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 22

def initialize(*)
  super
  self.encoding = "utf-8"
  @allow_concurrency             = nil
  @consider_all_requests_local   = false
  @filter_parameters             = []
  @filter_redirect               = []
  @helpers_paths                 = []
  @serve_static_files            = true
  @static_cache_control          = nil
  @force_ssl                     = false
  @ssl_options                   = {}
  @session_store                 = :cookie_store
  @session_options               = {}
  @time_zone                     = "UTC"
  @beginning_of_week             = :monday
  @has_explicit_log_level        = false
  @log_level                     = nil
  @middleware                    = app_middleware
  @generators                    = app_generators
  @cache_store                   = [ :file_store, "#{root}/tmp/cache/" ]
  @railties_order                = [:all]
  @relative_url_root             = ENV["RAILS_RELATIVE_URL_ROOT"]
  @reload_classes_only_on_change = true
  @file_watcher                  = ActiveSupport::FileUpdateChecker
  @exceptions_app                = nil
  @autoflush_log                 = true
  @log_formatter                 = ActiveSupport::Logger::SimpleFormatter.new
  @eager_load                    = nil
  @secret_token                  = nil
  @secret_key_base               = nil
  @x                             = Custom.new

  @assets = ActiveSupport::OrderedOptions.new
  @assets.enabled                  = true
  @assets.paths                    = []
  @assets.precompile               = [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) },
                                       /(?:\/|\\|\A)application\.(css|js)$/ ]
  @assets.prefix                   = "/assets"
  @assets.version                  = '1.0'
  @assets.debug                    = false
  @assets.compile                  = true
  @assets.digest                   = false
  @assets.cache_store              = [ :file_store, "#{root}/tmp/cache/assets/#{Rails.env}/" ]
  @assets.js_compressor            = nil
  @assets.css_compressor           = nil
  @assets.logger                   = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rails::Railtie::Configuration

Instance Attribute Details

#allow_concurrency (rw)

[ GitHub ]

#asset_host (rw)

[ GitHub ]

#assets (rw)

[ GitHub ]

#autoflush_log (rw)

[ GitHub ]

#beginning_of_week (rw)

[ GitHub ]

#cache_classes (rw)

[ GitHub ]

#cache_store (rw)

[ GitHub ]

#colorize_logging (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 135

def colorize_logging
  ActiveSupport::LogSubscriber.colorize_logging
end

#colorize_logging=(val) (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 139

def colorize_logging=(val)
  ActiveSupport::LogSubscriber.colorize_logging = val
  self.generators.colorize_logging = val
end

#consider_all_requests_local (rw)

[ GitHub ]

#console (rw)

[ GitHub ]

#eager_load (rw)

[ GitHub ]

#encoding (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 20

attr_reader :encoding

#encoding=(value) (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 71

def encoding=(value)
  @encoding = value
  silence_warnings do
    Encoding.default_external = value
    Encoding.default_internal = value
  end
end

#exceptions_app (rw)

[ GitHub ]

#file_watcher (rw)

[ GitHub ]

#filter_parameters (rw)

[ GitHub ]

#filter_redirect (rw)

[ GitHub ]

#force_ssl (rw)

[ GitHub ]

#helpers_paths (rw)

[ GitHub ]

#log_formatter (rw)

[ GitHub ]

#log_level (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 131

def log_level
  @log_level ||= (Rails.env.production? ? :info : :debug)
end

#log_level=(level) (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 126

def log_level=(level)
  @has_explicit_log_level = !!(level)
  @log_level = level
end

#log_tags (rw)

[ GitHub ]

#logger (rw)

[ GitHub ]

#railties_order (rw)

[ GitHub ]

#relative_url_root (rw)

[ GitHub ]

#reload_classes_only_on_change (rw)

[ GitHub ]

#secret_key_base (rw)

[ GitHub ]

#secret_token (rw)

[ GitHub ]

#serve_static_assets (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 153

def serve_static_assets
  ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
  serve_static_files
end

#serve_static_assets=(value) (rw)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 158

def serve_static_assets=(value)
  ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
  self.serve_static_files = value
end

#serve_static_files (rw)

[ GitHub ]

#session_options (rw)

[ GitHub ]

#ssl_options (rw)

[ GitHub ]

#static_cache_control (rw)

[ GitHub ]

#time_zone (rw)

[ GitHub ]

#x (rw)

[ GitHub ]

Instance Method Details

#annotations

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 186

def annotations
  SourceAnnotationExtractor::Annotation
end

#database_configuration

Loads and returns the entire raw configuration of database from values stored in config/database.yml.

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 97

def database_configuration
  path = paths["config/database"].existent.first
  yaml = Pathname.new(path) if path

  config = if yaml && yaml.exist?
    require "yaml"
    require "erb"
    YAML.load(ERB.new(yaml.read).result) || {}
  elsif ENV['DATABASE_URL']
    # Value from ENV['DATABASE_URL'] is set to default database connection
    # by Active Record.
    {}
  else
    raise "Could not load database configuration. No such file - #{paths["config/database"].instance_variable_get(:@paths)}"
  end

  config
rescue Psych::SyntaxError => e
  raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
        "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
        "Error: #{e.message}"
rescue => e
  raise e, "Cannot load `Rails.application.database_configuration`:\n#{e.message}", e.backtrace
end

#paths

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 79

def paths
  @paths ||= begin
    paths = super
    paths.add "config/database",    with: "config/database.yml"
    paths.add "config/secrets",     with: "config/secrets.yml"
    paths.add "config/environment", with: "config/environment.rb"
    paths.add "lib/templates"
    paths.add "log",                with: "log/#{Rails.env}.log"
    paths.add "public"
    paths.add "public/javascripts"
    paths.add "public/stylesheets"
    paths.add "tmp"
    paths
  end
end

#session_store(*args)

[ GitHub ]

  
# File 'railties/lib/rails/application/configuration.rb', line 163

def session_store(*args)
  if args.empty?
    case @session_store
    when :disabled
      nil
    when :active_record_store
      begin
        ActionDispatch::Session::ActiveRecordStore
      rescue NameError
        raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
          "Please add `activerecord-session_store` to your Gemfile to use it."
      end
    when Symbol
      ActionDispatch::Session.const_get(@session_store.to_s.camelize)
    else
      @session_store
    end
  else
    @session_store = args.shift
    @session_options = args.shift || {}
  end
end