Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6212

Show
Ignore:
Timestamp:
02/23/07 00:32:27 (1 year ago)
Author:
david
Message:

Added config/initializers where all ruby files within it are automatically loaded after the Rails configuration is done, so you don't have to litter the environment.rb file with a ton of mixed stuff [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r6197 r6212  
    11*SVN* 
     2 
     3* Added config/initializers where all ruby files within it are automatically loaded after the Rails configuration is done, so you don't have to litter the environment.rb file with a ton of mixed stuff [DHH] 
    24 
    35* For new apps, generate a random secret for the cookie-based session store.  [Jeremy Kemper] 
  • trunk/railties/environments/environment.rb

    r6211 r6212  
    5050 
    5151  # See Rails::Configuration for more options 
     52   
     53  # Application configuration should go into files in config/initializers 
     54  # -- all .rb files in that directory is automatically loaded 
    5255end 
    53  
    54 # Add new inflection rules using the following format  
    55 # (all these examples are active by default): 
    56 # Inflector.inflections do |inflect| 
    57 #   inflect.plural /^(ox)$/i, '\1en' 
    58 #   inflect.singular /^(ox)en/i, '\1' 
    59 #   inflect.irregular 'person', 'people' 
    60 #   inflect.uncountable %w( fish sheep ) 
    61 # end 
    62  
    63 # Add new mime types for use in respond_to blocks: 
    64 # Mime::Type.register "text/richtext", :rtf 
    65 # Mime::Type.register "application/x-mobile", :mobile 
    66  
    67 # Include your application configuration below 
  • trunk/railties/lib/initializer.rb

    r6127 r6212  
    7171    # * #load_observers 
    7272    # * #initialize_routing 
     73    # * #after_initialize 
     74    # * #load_application_initializers 
    7375    # 
    7476    # (Note that #load_environment is invoked twice, once at the start and 
     
    113115      # the framework is now fully initialized 
    114116      after_initialize 
     117 
     118      load_application_initializers 
    115119    end 
    116120 
     
    335339    end 
    336340 
     341    def load_application_initializers 
     342      Dir["#{RAILS_ROOT}/config/initializers/**/*.rb"].each do |initializer| 
     343        load(initializer) 
     344      end 
     345    end 
     346 
    337347    protected 
    338348      # Return a list of plugin paths within base_path.  A plugin path is 
  • trunk/railties/lib/rails_generator/generators/applications/app/app_generator.rb

    r5691 r6212  
    122122    app/views/layouts 
    123123    config/environments 
     124    config/initializers 
    124125    db 
    125126    doc 
  • trunk/railties/Rakefile

    r5390 r6212  
    3939 
    4040 
    41 BASE_DIRS   = %w(  
    42   app config/environments components db doc log lib lib/tasks public script script/performance script/process test vendor vendor/plugins 
    43   tmp/sessions tmp/cache tmp/sockets tmp/pids 
     41BASE_DIRS = %w(  
     42  app 
     43  config/environments 
     44  config/initializers 
     45  components 
     46  db 
     47  doc 
     48  log 
     49  lib 
     50  lib/tasks 
     51  public 
     52  script 
     53  script/performance 
     54  script/process 
     55  test 
     56  vendor 
     57  vendor/plugins 
     58  tmp/sessions 
     59  tmp/cache 
     60  tmp/sockets 
     61  tmp/pids 
    4462) 
    4563