diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-08-14 16:31:14 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-08-14 16:31:14 +0100 |
commit | 2ebe8d275efa53af967b09ad66dab68acc1aed98 (patch) | |
tree | b0b3e42c277b213788b55558aef3579f4e242300 /railties/lib | |
parent | 73ef94e9675ef6db85f18f1e3c70bf6ddfc1260a (diff) | |
parent | 8cb14ee1203c9ed380c4b192e8730757a52d43cb (diff) | |
download | rails-2ebe8d275efa53af967b09ad66dab68acc1aed98.tar.gz rails-2ebe8d275efa53af967b09ad66dab68acc1aed98.tar.bz2 rails-2ebe8d275efa53af967b09ad66dab68acc1aed98.zip |
Merge commit 'mainstream/master'
Conflicts:
actionpack/lib/action_controller/request.rb
actionpack/lib/action_controller/resources.rb
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/commands/runner.rb | 2 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 33 | ||||
-rw-r--r-- | railties/lib/rails/gem_dependency.rb | 2 | ||||
-rw-r--r-- | railties/lib/tasks/databases.rake | 9 |
4 files changed, 33 insertions, 13 deletions
diff --git a/railties/lib/commands/runner.rb b/railties/lib/commands/runner.rb index 926bc26344..14159c3893 100644 --- a/railties/lib/commands/runner.rb +++ b/railties/lib/commands/runner.rb @@ -42,7 +42,7 @@ if code_or_file.nil? $stderr.puts "Run '#{$0} -h' for help." exit 1 elsif File.exist?(code_or_file) - eval(File.read(code_or_file)) + eval(File.read(code_or_file), nil, code_or_file) else eval(code_or_file) end diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index a2d08e2938..6576cd368b 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -340,9 +340,11 @@ Run `rake gems:install` to install the missing gems. end def load_view_paths - ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes - ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer) - ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller) + if configuration.frameworks.include?(:action_view) + ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes + ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller) + ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer) + end end # Eager load application classes @@ -440,9 +442,11 @@ Run `rake gems:install` to install the missing gems. # paths have already been set, it is not changed, otherwise it is # set to use Configuration#view_path. def initialize_framework_views - view_path = ActionView::PathSet::Path.new(configuration.view_path, false) - ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer) - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty? + if configuration.frameworks.include?(:action_view) + view_path = ActionView::PathSet::Path.new(configuration.view_path, false) + ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer) + ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty? + end end # If Action Controller is not one of the loaded frameworks (Configuration#frameworks) @@ -688,13 +692,17 @@ Run `rake gems:install` to install the missing gems. # You can add gems with the #gem method. attr_accessor :gems - # Adds a single Gem dependency to the rails application. + # Adds a single Gem dependency to the rails application. By default, it will require + # the library with the same name as the gem. Use :lib to specify a different name. # # # gem 'aws-s3', '>= 0.4.0' # # require 'aws/s3' # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ # :source => "http://code.whytheluckystiff.net" # + # To require a library be installed, but not attempt to load it, pass :lib => false + # + # config.gem 'qrp', :version => '0.4.1', :lib => false def gem(name, options = {}) @gems << Rails::GemDependency.new(name, options) end @@ -764,6 +772,17 @@ Run `rake gems:install` to install the missing gems. ::RAILS_ROOT.replace @root_path end + # Enable threaded mode. Allows concurrent requests to controller actions and + # multiple database connections. Also disables automatic dependency loading + # after boot + def threadsafe! + self.cache_classes = true + self.dependency_loading = false + self.active_record.allow_concurrency = true + self.action_controller.allow_concurrency = true + self + end + # Loads and returns the contents of the #database_configuration_file. The # contents of the file are processed via ERB before being sent through # YAML::load. diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index f8d97840c1..471e03fa5f 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -58,7 +58,7 @@ module Rails def load return if @loaded || @load_paths_added == false - require(@lib || @name) + require(@lib || @name) unless @lib == false @loaded = true rescue LoadError puts $!.to_s diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 5ec712a02d..21c81b3fb5 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -182,11 +182,11 @@ namespace :db do end namespace :fixtures do - desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." + desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." task :load => :environment do require 'active_record/fixtures' ActiveRecord::Base.establish_connection(Rails.env) - base_dir = File.join(Rails.root, 'test', 'fixtures') + base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| @@ -194,7 +194,7 @@ namespace :db do end end - desc "Search for a fixture given a LABEL or ID." + desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." task :identify => :environment do require "active_record/fixtures" @@ -203,7 +203,8 @@ namespace :db do puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label - Dir["#{RAILS_ROOT}/test/fixtures/**/*.yml"].each do |file| + base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') + Dir["#{base_dir}/**/*.yml"].each do |file| if data = YAML::load(ERB.new(IO.read(file)).result) data.keys.each do |key| key_id = Fixtures.identify(key) |