Supported Options for Rails::Configuration

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 config/environment.rb). I spent a couple of minutes coming up with this script - hopefully he (and someone else) will find it useful:

Script to discover all Rails::Configuration options
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:

Script output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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!