diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-02 00:42:20 +0200 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-03 23:32:11 +1000 |
commit | 83a58e066090c5238822b712e0cfa8b72ddb02e5 (patch) | |
tree | e7ccebdec5d5b564d4fe15f0d94521e1c1866bfb /railties/lib/rails/application.rb | |
parent | 53efdc2eefcf7ce98148d9ca7f2f4d4c1f900866 (diff) | |
download | rails-83a58e066090c5238822b712e0cfa8b72ddb02e5.tar.gz rails-83a58e066090c5238822b712e0cfa8b72ddb02e5.tar.bz2 rails-83a58e066090c5238822b712e0cfa8b72ddb02e5.zip |
Add lib to load paths when application is inherited to be able to load lib code during configuration.
Diffstat (limited to 'railties/lib/rails/application.rb')
-rw-r--r-- | railties/lib/rails/application.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 7416e94eeb..85ae8cbbb1 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -67,6 +67,7 @@ module Rails raise "You cannot have more than one Rails::Application" if Rails.application super Rails.application = base.instance + Rails.application.add_lib_to_load_paths! ActiveSupport.run_load_hooks(:before_configuration, base.instance) end @@ -83,11 +84,21 @@ module Rails delegate :middleware, :to => :config + def add_lib_to_load_paths! + path = config.root.join('lib').to_s + $LOAD_PATH.unshift(path) if File.exists?(path) + end + def require_environment! environment = paths.config.environment.to_a.first require environment if environment end + def eager_load! + railties.all(&:eager_load!) + super + end + def routes @routes ||= ActionDispatch::Routing::RouteSet.new end |