# Cheat sheet for Rails 2.x configuration elements
# Created by: Anthony Eden (anthony.mp)
# License: Attribution-Noncommercial-Share Alike 3.0 United States
# License URL: http://creativecommons.org/licenses/by-nc-sa/3.0/us/
# Rails Configuration elements and their default values
config.root_path = begin
raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT)
raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT)
# Pathname is incompatible with Windows, but Windows doesn't have
# real symlinks so File.expand_path is safe.
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
Pathname.new(::RAILS_ROOT).realpath.to_s
end
end
config.cache_classes = false
config.controller_paths = begin
paths = [File.join(root_path, 'app', 'controllers')]
paths.concat builtin_directories
paths
end
config.database_configuration_file = File.join(root_path, 'config', 'database.yml')
config.routes_configuration_file = File.join(root_path, 'config', 'routes.rb') # new in 2.1
config.frameworks = ['active_record', 'action_controller', 'action_view', 'action_mailer', 'active_resource']
config.load_paths = begin
paths = ["#{root_path}/test/mocks/#{environment}"]
# Add the app's controller directory
paths.concat(Dir["#{root_path}/app/controllers/"])
# Then components subdirectories.
paths.concat(Dir["#{root_path}/components/[_a-z]*"])
# Followed by the standard includes.
paths.concat %w(
app
app/models
app/controllers
app/helpers
app/services
components
config
lib
vendor
).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
paths.concat builtin_directories
end
config.load_once_paths = []
config.log_level = environment == 'production' ? :info : :debug
config.log_path = File.join(root_path, 'log', "#{environment}.log")
config.logger = begin
logger = ActiveSupport::BufferedLogger.new(configuration.log_path)
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)
logger.auto_flushing = false if configuration.environment == "production"
rescue StandardError =>e
logger = ActiveSupport::BufferedLogger.new(STDERR)
logger.level = ActiveSupport::BufferedLogger::WARN
logger.warn(
"Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " +
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
)
end
config.cache_store = begin # new in 2.1
if File.exist?("#{root_path}/tmp/cache/")
[ :file_store, "#{root_path}/tmp/cache/" ]
else
:memory_store
end
end
config.view_path = File.join(root_path, 'app', 'views')
config.whiny_nils = false
config.plugins = nil # Loads all plugins
config.plugin_paths = ["#{root_path}/vendor/plugins"]
config.plugin_locators = [Plugin::FileSystemLocator]
config.plugin_loader = Plugin::Loader
config.reload_plugins = true # new in 2.1
config.gems = [] # new in 2.1, use config.gem('gem_name', options) to add gems
config.time_zone = nil # new in 2.1, use rake -D time to get tasks for determining time zones
# ActionController configuration elements
config.action_controller.view_controller_internals = true # removed in 2.1
config.action_controller.protected_variables_cache = nil # removed in 2.1
config.action_controller.asset_host = ''
config.action_controller.consider_all_requests_local = true
config.action_controller.debug_routes = true
config.action_controller.allow_concurrency = false
config.action_controller.params_parsers = {
Mime::MULTIPART_FORM => :multipart_form,
Mime::URL_ENCODED_FORM => :url_encoded_form,
Mime::XML => :xml_simple,
Mime::JSON => :json # new in 2.1
}
config.action_controller.default_charset = 'utf-8'
config.action_controller.logger = config.logger
config.action_controller.template_class = ActionView::Base # removed in 2.1
config.action_controller.ignore_missing_templates = nil # removed in 2.1
config.action_controller.resource_action_separator = '/'
config.action_controller.request_forgery_protection_token = nil
config.action_controller.optimise_named_routes = true
config.action_controller.allow_forgery_protection = true
# ActionView configuration elements
config.action_view.erb_trim_mode = '-'
config.action_view.cache_template_loading = false
config.action_view.cache_template_extensions = true # deprecated in 2.1
config.action_view.local_assigns_support_string_keys = true # removed in 2.1
config.action_view.debug_rjs = false
config.action_view.erb_variable = '_erbout'
config.action_view.computed_public_paths = {}
config.action_view.logger = config.logger # delegated to action controller in 2.1
# ActionMailer configuration elements
config.action_mailer.logger = config.logger
config.action_mailer.template_extensions = ['erb', 'builder', 'rhtml', 'rxml']
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => 'localhost.localdomain',
:user_name => nil,
:password => nil,
:authentication => nil
}
config.action_mailer.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t'
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.deliveries = []
config.action_mailer.default_charset = 'utf-8'
config.action_mailer.default_content_type = 'text/plain'
config.action_mailer.default_mime_version = "1.0"
config.action_mailer.default_implicit_parts_order = ["text/html", "text/enriched", "text/plain"]
# ActiveRecord configuration elements
config.active_record.logger = config.logger
config.active_record.configurations = {}
config.active_record.primary_key_prefix_type = nil
config.active_record.table_name_prefix = ''
config.active_record.table_name_suffix = ''
config.active_record.pluralize_table_names = true
config.active_record.colorize_logging = true
config.active_record.default_timezone = :local
config.active_record.allow_concurrency = false
config.active_record.schema_format = :ruby
config.active_record.store_full_sti_class = false # new in 2.1
# ActiveResource configuration elements
config.active_resource.logger = config.logger