Ben Askins asked today on the Ruby on Rails Australia mailing list if anyone knew where to find a single list of available Rails::Configuration options (usually set within Rails::Initializer.run in environment.rb). I spent a couple of minutes coming up with this script – hopefully he (and someone else) will find it useful:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# You can run this from the Rails console
puts "Note: config is an instance of is Rails::Configuration"
ObjectSpace.each_object do |o| 
  if (o.class == Rails::Configuration)
    o.instance_variables.each do |iv|
      iv = iv.gsub!(/@/, '')
      puts "config.#{iv} (#{o.instance_eval(iv).class})"
      if (o.instance_eval(iv).class == Rails::OrderedOptions)
        options = eval("#{iv.camelize}::Base.class_variables")
        puts "  All available options are:" unless options.size == 0
        eval("#{iv.camelize}::Base.class_variables").each do |cv|
          puts "  #{cv.gsub!(/@@/, '')}"
        end
      end
    end
  end
end

And now for the rabbit:

config.database_configuration_file (String)
config.breakpoint_server (TrueClass)
config.view_path (String)
config.action_mailer (Rails::OrderedOptions)
  All available options are:
  default_mime_version
  default_charset
  raise_delivery_errors
  deliveries
  server_settings
  default_implicit_parts_order
  delivery_method
  default_content_type
  logger
  perform_deliveries
  default_url_options
config.load_once_paths (Array)
config.plugin_paths (Array)
config.controller_paths (Array)
config.active_record (Rails::OrderedOptions)
  All available options are:
  default_timezone
  configurations
  record_timestamps
  defined_connections
  colorize_logging
  lock_optimistically
  table_name_suffix
  verification_timeout
  allow_concurrency
  primary_key_prefix_type
  schema_format
  pluralize_table_names
  subclasses
  logger
  active_connections
  generate_read_methods
  table_name_prefix
  content_types
config.action_controller (Rails::OrderedOptions)
  All available options are:
  asset_host
  exempt_from_layout
  view_controller_internals
  default_charset
  ignore_missing_templates
  param_parsers
  allow_concurrency
  consider_all_requests_local
  rescue_templates
  protected_variables_cache
  rescue_responses
  logger
  template_class
  debug_routes
  page_cache_extension
  page_cache_directory
  fragment_cache_store
  perform_caching
config.load_paths (Array)
config.plugins (NilClass)
config.action_web_service (Rails::OrderedOptions)
config.log_path (String)
config.frameworks (Array)
config.whiny_nils (TrueClass)
config.cache_classes (FalseClass)
config.action_view (Rails::OrderedOptions)
  All available options are:
  default_form_builder
  cached_template_extension
  local_assigns_support_string_keys
  method_names
  cache_template_loading
  inline_template_count
  debug_rjs
  template_args
  cache_template_extensions
  field_error_proc
  template_handlers
  erb_trim_mode
  compile_time
  erb_variable
  protocols
  attributes
  tags
  javascript_default_sources
config.log_level (Symbol)

Hope that helps!

6 Responses to “Supported Options for Rails::Configuration”

  1. Ben Askins Says:

    Thanks Nathan – that will come in very handy.

  2. Tim Lucas Says:

    Looks like a great candidate for a cheat sheet!

  3. Nathan de Vries Says:

    It’s a bit hacky though, isn’t it? Is there some way of accessing Rails::Configuration other than seeking through ObjectSpace.each_object {}?

  4. Ben Askins Says:

    Tim: next time there’s a rainy weekend I’ll try to go through each of these, understand what they do and put together a cheat sheet.

  5. Ben Askins Says:

    Nathan: I tried to get a similar list by reflecting on the config object within the initializer block in environment.rb. I found I couldn’t get any deeper than than the top-evel config.* methods. Your method may be a hack… but it works!

  6. Vish Says:

    I just chanced upon this blog entry.

    Nathan asked: >Is there some way of accessing Rails::Configuration >other than seeking through ObjectSpace.each_object {}?

    Of course. Just do o = Rails::Configuration.new instead of ObjectSpace.each_object. :-)

Leave a Reply