aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-03-31 07:47:58 -0700
committerXavier Noria <fxn@hashref.com>2010-03-31 07:47:58 -0700
commit824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8 (patch)
tree1967c2a945d6e131d467fb4f0178a0f60e01ae8a /railties
parent1ed1652bef981d9402797b6cb9f0920a40eea21a (diff)
parentdb28d407f76a790a31e27bf51560e23425dd6944 (diff)
downloadrails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.tar.gz
rails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.tar.bz2
rails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.zip
Merge commit 'rails/master'
Diffstat (limited to 'railties')
-rw-r--r--railties/Rakefile8
-rw-r--r--railties/guides/source/configuring.textile18
-rw-r--r--railties/lib/rails/application/routes_reloader.rb2
-rw-r--r--railties/lib/rails/commands/server.rb5
-rw-r--r--railties/lib/rails/engine.rb9
-rw-r--r--railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb2
-rw-r--r--railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb12
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt13
-rw-r--r--railties/lib/rails/generators/rails/resource/resource_generator.rb1
-rw-r--r--railties/lib/rails/tasks/documentation.rake69
-rw-r--r--railties/lib/rails/test_help.rb2
-rw-r--r--railties/test/rails_info_controller_test.rb4
12 files changed, 80 insertions, 65 deletions
diff --git a/railties/Rakefile b/railties/Rakefile
index 6368456366..d88036f829 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -1,5 +1,3 @@
-require File.expand_path('../../load_paths', __FILE__)
-
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
@@ -60,10 +58,8 @@ Rake::RDocTask.new { |rdoc|
rdoc.options << '--charset' << 'utf-8'
rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
rdoc.rdoc_files.include('README', 'CHANGELOG')
- rdoc.rdoc_files.include('lib/*.rb')
- rdoc.rdoc_files.include('lib/rails/*.rb')
- rdoc.rdoc_files.include('lib/rails/generators/*.rb')
- rdoc.rdoc_files.include('lib/rails/commands/**/*.rb')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+ rdoc.rdoc_files.exclude('lib/rails/generators/**/templates/*')
}
# Generate GEM ----------------------------------------------------------------------------
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 5418ad7dd4..55077bcd24 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -9,24 +9,24 @@ endprologue.
h3. Locations for Initialization Code
-Rails offers (at least) five good spots to place initialization code:
+Rails offers (at least) four good spots to place initialization code:
-* Preinitializers
-* environment.rb
+* application.rb
* Environment-specific Configuration Files
* Initializers (load_application_initializers)
* After-Initializers
-h3. Using a Preinitializer
+h3. Running Code Before Rails
-Rails allows you to use a preinitializer to run code before the framework itself is loaded. If you save code in +RAILS_ROOT/config/preinitializer.rb+, that code will be the first thing loaded, before any of the framework components (Active Record, Action Pack, and so on.) If you want to change the behavior of one of the classes that is used in the initialization process, you can do so in this file.
+To run some code before Rails itself is loaded, simply put it above the call to
++require 'rails/all'+ in your +application.rb+.
h3. Configuring Rails Components
-In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +environment.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 +environment.rb+ file includes one setting:
+In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +application.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 +application.rb+ file includes one setting:
<ruby>
-config.time_zone = 'UTC'
+config.filter_parameters << :password
</ruby>
This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object:
@@ -53,8 +53,6 @@ h4. Rails General Configuration
* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+.
-* +config.frameworks+ accepts an array of rails framework components that should be loaded. (Defaults to +:active_record+, +:action_controller+, +:action_view+, +:action_mailer+, and +:active_resource+).
-
* +config.load_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +load_paths+.
* +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
@@ -133,6 +131,8 @@ h4. Configuring Action Controller
* +config.action_controller.asset_host+ provides a string that is prepended to all of the URL-generating helpers in +AssetHelper+. This is designed to allow moving all javascript, CSS, and image files to a separate asset host.
+* +config.action_controller.asset_path+ allows you to override the default asset path generation by providing your own instructions.
+
* +config.action_controller.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ to specify which requests should provide debugging information on errors.
* +config.action_controller.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Instead, you should simply call +config.threadsafe!+ inside your +production.rb+ file, which makes all the necessary adjustments.
diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb
index a5154f4bba..a2b3622df8 100644
--- a/railties/lib/rails/application/routes_reloader.rb
+++ b/railties/lib/rails/application/routes_reloader.rb
@@ -27,7 +27,7 @@ module Rails
routes.clear!
paths.each { |path| load(path) }
- ActionController.base_hook { routes.finalize! }
+ ActiveSupport.on_load(:action_controller) { routes.finalize! }
nil
ensure
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index c57660c0d1..3f74cd49fc 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -54,6 +54,11 @@ module Rails
trap(:INT) { exit }
puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
+ #Create required tmp directories if not found
+ %w(cache pids sessions sockets).each do |dir_to_make|
+ FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make))
+ end
+
super
ensure
# The '-h' option calls exit before @options is set.
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 85cae75bce..e9013348b5 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -180,8 +180,13 @@ module Rails
initializer :add_view_paths do
views = paths.app.views.to_a
- ActionController.base_hook { prepend_view_path(views) } if defined?(ActionController)
- ActionMailer.base_hook { prepend_view_path(views) } if defined?(ActionMailer)
+ ActiveSupport.on_load(:action_controller) do
+ prepend_view_path(views)
+ end
+
+ ActiveSupport.on_load(:action_mailer) do
+ prepend_view_path(views)
+ end
end
initializer :add_metals do |app|
diff --git a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb
index a3dc38d9e4..867fc8c985 100644
--- a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb
+++ b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
require 'rails/performance_test_help'
# Profiling results for each test method are written to tmp/performance.
-class BrowsingTest < ActionController::PerformanceTest
+class BrowsingTest < ActionDispatch::PerformanceTest
def test_homepage
get '/'
end
diff --git a/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb b/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb
deleted file mode 100644
index 99fd2f45bc..0000000000
--- a/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-module Rails
- module Generators
- # TODO Deprecate me in a release > Rails 3.0
- class ModelSubclassGenerator < Base
- desc "model_subclass is deprecated. Invoke model with --parent option instead."
-
- def say_deprecation_warn
- say self.class.desc
- end
- end
- end
-end
diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt
index e94c0bfc77..733e321c94 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt
+++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt
@@ -1,10 +1,23 @@
+require 'rake'
require 'rake/testtask'
+require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the <%= file_name %> plugin.'
Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
end
+
+desc 'Generate documentation for the <%= file_name %> plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = '<%= class_name %>'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end \ No newline at end of file
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index 1e78945a7e..8a46708009 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -1,5 +1,6 @@
require 'rails/generators/resource_helpers'
require 'rails/generators/rails/model/model_generator'
+require 'active_support/core_ext/object/blank'
module Rails
module Generators
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index f2fee45594..957c375f6a 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -1,4 +1,9 @@
namespace :doc do
+ def gem_path(gem_name)
+ path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first
+ yield File.dirname(path) if path
+ end
+
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
Rake::RDocTask.new("app") { |rdoc|
rdoc.rdoc_dir = 'doc/app'
@@ -11,54 +16,56 @@ namespace :doc do
rdoc.rdoc_files.include('lib/**/*.rb')
}
- desc 'Generate documentation for the Rails framework. Specify path with RAILS_PATH="/path/to/rails"'
- path = ENV['RAILS_PATH']
- unless path && File.directory?(path)
- task :rails do
- if path
- $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}"
- else
- $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set"
+ desc 'Generate documentation for the Rails framework.'
+ Rake::RDocTask.new("rails") { |rdoc|
+ rdoc.rdoc_dir = 'doc/api'
+ rdoc.template = "#{ENV['template']}.rb" if ENV['template']
+ rdoc.title = "Rails Framework Documentation"
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+
+ gem_path('actionmailer') do |actionmailer|
+ %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
+ rdoc.rdoc_files.include("#{actionmailer}/#{file}")
end
end
- else
- Rake::RDocTask.new("rails") { |rdoc|
- version = "-#{Rails::VERSION::STRING}" unless ENV['RAILS_PATH']
- rdoc.rdoc_dir = 'doc/api'
- rdoc.template = "#{ENV['template']}.rb" if ENV['template']
- rdoc.title = "Rails Framework Documentation"
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
-
- %w(README CHANGELOG lib/action_mailer/base.rb).each do |file|
- rdoc.rdoc_files.include("#{path}/actionmailer#{version}/#{file}")
- end
- %w(README CHANGELOG lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{path}/actionpack#{version}/#{file}")
+ gem_path('actionpack') do |actionpack|
+ %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{actionpack}/#{file}")
end
+ end
- %w(README CHANGELOG lib/active_model/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{path}/activemodel#{version}/#{file}")
+ gem_path('activemodel') do |activemodel|
+ %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
+ rdoc.rdoc_files.include("#{activemodel}/#{file}")
end
+ end
+ gem_path('activerecord') do |activerecord|
%w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{path}/activerecord#{version}/#{file}")
+ rdoc.rdoc_files.include("#{activerecord}/#{file}")
end
+ end
+ gem_path('activeresource') do |activeresource|
%w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
- rdoc.rdoc_files.include("#{path}/activeresource#{version}/#{file}")
+ rdoc.rdoc_files.include("#{activeresource}/#{file}")
end
+ end
+ gem_path('activesupport') do |activesupport|
%w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
- rdoc.rdoc_files.include("#{path}/activesupport#{version}/#{file}")
+ rdoc.rdoc_files.include("#{activesupport}/#{file}")
end
+ end
- %w(README CHANGELOG MIT-LICENSE lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
- rdoc.rdoc_files.include("#{path}/railties#{version}/#{file}")
+ gem_path('railties') do |railties|
+ %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
+ rdoc.rdoc_files.include("#{railties}/#{file}")
end
- }
- end
+ end
+ }
plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb
index 6522c94ad6..3ce4e2c780 100644
--- a/railties/lib/rails/test_help.rb
+++ b/railties/lib/rails/test_help.rb
@@ -30,7 +30,7 @@ end
class ActionController::TestCase
setup do
- @router = Rails.application.routes
+ @routes = Rails.application.routes
end
end
diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb
index 05ec359f61..aa76979c27 100644
--- a/railties/test/rails_info_controller_test.rb
+++ b/railties/test/rails_info_controller_test.rb
@@ -15,9 +15,9 @@ class InfoControllerTest < ActionController::TestCase
match '/rails/info/properties' => "rails/info#properties"
end
@controller.stubs(:consider_all_requests_local? => false, :local_request? => true)
- @router = Rails.application.routes
+ @routes = Rails.application.routes
- Rails::InfoController.send(:include, @router.url_helpers)
+ Rails::InfoController.send(:include, @routes.url_helpers)
end
test "info controller does not allow remote requests" do