railties 3.0.0.rc → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGELOG +80 -75
  2. data/README.rdoc +1 -1
  3. data/guides/assets/stylesheets/main.css +14 -14
  4. data/guides/rails_guides.rb +20 -1
  5. data/guides/rails_guides/generator.rb +7 -7
  6. data/guides/source/2_3_release_notes.textile +5 -5
  7. data/guides/source/3_0_release_notes.textile +4 -3
  8. data/guides/source/action_controller_overview.textile +32 -17
  9. data/guides/source/action_view_overview.textile +44 -44
  10. data/guides/source/active_record_basics.textile +2 -2
  11. data/guides/source/active_record_querying.textile +7 -7
  12. data/guides/source/active_record_validations_callbacks.textile +20 -20
  13. data/guides/source/active_support_core_extensions.textile +370 -198
  14. data/guides/source/ajax_on_rails.textile +17 -17
  15. data/guides/source/api_documentation_guidelines.textile +3 -3
  16. data/guides/source/association_basics.textile +2 -2
  17. data/guides/source/caching_with_rails.textile +5 -5
  18. data/guides/source/command_line.textile +8 -8
  19. data/guides/source/configuring.textile +6 -6
  20. data/guides/source/contributing_to_rails.textile +14 -11
  21. data/guides/source/debugging_rails_applications.textile +8 -6
  22. data/guides/source/form_helpers.textile +1 -1
  23. data/guides/source/generators.textile +34 -30
  24. data/guides/source/getting_started.textile +13 -13
  25. data/guides/source/i18n.textile +12 -1
  26. data/guides/source/index.html.erb +4 -0
  27. data/guides/source/initialization.textile +67 -72
  28. data/guides/source/layout.html.erb +1 -0
  29. data/guides/source/layouts_and_rendering.textile +9 -9
  30. data/guides/source/nested_model_forms.textile +7 -7
  31. data/guides/source/plugins.textile +1 -1
  32. data/guides/source/rails_application_templates.textile +2 -2
  33. data/guides/source/routing.textile +27 -5
  34. data/guides/source/security.textile +6 -6
  35. data/guides/w3c_validator.rb +9 -9
  36. data/lib/rails/application.rb +1 -0
  37. data/lib/rails/application/configuration.rb +1 -1
  38. data/lib/rails/code_statistics.rb +4 -4
  39. data/lib/rails/commands.rb +1 -1
  40. data/lib/rails/commands/dbconsole.rb +1 -1
  41. data/lib/rails/commands/plugin.rb +1 -1
  42. data/lib/rails/commands/runner.rb +1 -1
  43. data/lib/rails/deprecation.rb +31 -52
  44. data/lib/rails/engine.rb +1 -1
  45. data/lib/rails/engine/configuration.rb +28 -1
  46. data/lib/rails/generators.rb +2 -2
  47. data/lib/rails/generators/actions.rb +3 -3
  48. data/lib/rails/generators/active_model.rb +3 -3
  49. data/lib/rails/generators/base.rb +1 -1
  50. data/lib/rails/generators/rails/app/app_generator.rb +9 -3
  51. data/lib/rails/generators/rails/app/templates/Gemfile +2 -2
  52. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +4 -13
  53. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
  54. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +4 -0
  55. data/lib/rails/generators/rails/app/templates/config/routes.rb +4 -4
  56. data/lib/rails/generators/rails/app/templates/public/index.html +0 -23
  57. data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +1 -1
  58. data/lib/rails/generators/rails/generator/USAGE +3 -2
  59. data/lib/rails/generators/rails/migration/USAGE +4 -4
  60. data/lib/rails/generators/rails/plugin/USAGE +1 -1
  61. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  62. data/lib/rails/generators/test_case.rb +1 -1
  63. data/lib/rails/info_controller.rb +1 -1
  64. data/lib/rails/plugin.rb +1 -1
  65. data/lib/rails/rack/log_tailer.rb +2 -5
  66. data/lib/rails/railtie.rb +22 -22
  67. data/lib/rails/script_rails_loader.rb +2 -2
  68. data/lib/rails/tasks/documentation.rake +5 -5
  69. data/lib/rails/tasks/framework.rake +1 -1
  70. data/lib/rails/tasks/routes.rake +23 -9
  71. data/lib/rails/test_unit/testing.rake +3 -2
  72. data/lib/rails/version.rb +1 -1
  73. metadata +10 -10
@@ -1,62 +1,41 @@
1
1
  require "active_support/string_inquirer"
2
- require "active_support/deprecation"
3
-
4
- RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
5
- cattr_accessor :warned
6
- self.warned = false
7
-
8
- def target
9
- Rails.root
10
- end
11
-
12
- def replace(*args)
13
- warn(caller, :replace, *args)
14
- end
15
-
16
- def warn(callstack, called, args)
17
- unless warned
18
- ActiveSupport::Deprecation.warn("RAILS_ROOT is deprecated! Use Rails.root instead", callstack)
19
- self.warned = true
2
+ require "active_support/basic_object"
3
+
4
+ module Rails
5
+ module Initializer
6
+ def self.run(&block)
7
+ klass = Class.new(Rails::Application)
8
+ klass.instance_exec(klass.config, &block)
9
+ klass.initialize!
20
10
  end
21
11
  end
22
- end).new
23
-
24
- RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
25
- cattr_accessor :warned
26
- self.warned = false
27
-
28
- def target
29
- Rails.env
30
- end
31
12
 
32
- def replace(*args)
33
- warn(caller, :replace, *args)
34
- end
35
-
36
- def warn(callstack, called, args)
37
- unless warned
38
- ActiveSupport::Deprecation.warn("RAILS_ENV is deprecated! Use Rails.env instead", callstack)
39
- self.warned = true
13
+ class DeprecatedConstant < ActiveSupport::BasicObject
14
+ def self.deprecate(old, new)
15
+ constant = self.new(old, new)
16
+ eval "::#{old} = constant"
40
17
  end
41
- end
42
- end).new
43
-
44
- RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
45
- cattr_accessor :warned
46
- self.warned = false
47
18
 
48
- def target
49
- Rails.logger
50
- end
19
+ def initialize(old, new)
20
+ @old, @new = old, new
21
+ @target = ::Kernel.eval "proc { #{@new} }"
22
+ @warned = false
23
+ end
51
24
 
52
- def replace(*args)
53
- warn(caller, :replace, *args)
54
- end
25
+ def method_missing(meth, *args, &block)
26
+ ::ActiveSupport::Deprecation.warn("#{@old} is deprecated. Please use #{@new}") unless @warned
27
+ @warned = true
55
28
 
56
- def warn(callstack, called, args)
57
- unless warned
58
- ActiveSupport::Deprecation.warn("RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead", callstack)
59
- self.warned = true
29
+ target = @target.call
30
+ if target.respond_to?(meth)
31
+ target.send(meth, *args, &block)
32
+ else
33
+ super
34
+ end
60
35
  end
61
36
  end
62
- end).new
37
+
38
+ DeprecatedConstant.deprecate("RAILS_ROOT", "Rails.root.to_s")
39
+ DeprecatedConstant.deprecate("RAILS_ENV", "Rails.env")
40
+ DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "Rails.logger")
41
+ end
data/lib/rails/engine.rb CHANGED
@@ -119,7 +119,7 @@ module Rails
119
119
  root = File.exist?("#{root_path}/#{flag}") ? root_path : default
120
120
  raise "Could not find root path for #{self}" unless root
121
121
 
122
- Config::CONFIG['host_os'] =~ /mswin|mingw/ ?
122
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
123
123
  Pathname.new(root).expand_path : Pathname.new(root).realpath
124
124
  end
125
125
  end
@@ -48,6 +48,33 @@ module Rails
48
48
  def autoload_paths
49
49
  @autoload_paths ||= paths.autoload_paths
50
50
  end
51
+
52
+ def load_paths
53
+ ActiveSupport::Deprecation.warn "config.load_paths is deprecated. Please use config.autoload_paths instead."
54
+ autoload_paths
55
+ end
56
+
57
+ def load_paths=(paths)
58
+ ActiveSupport::Deprecation.warn "config.load_paths= is deprecated. Please use config.autoload_paths instead."
59
+ self.autoload_paths = paths
60
+ end
61
+
62
+ # Rails 3, by default, uses bundler, which shims the Kernel#gem method so that it should
63
+ # behave correctly for this deprecation.
64
+ def gem(name, options = {})
65
+ super name, options[:version] || ">= 0"
66
+ require options[:lib] || name
67
+ rescue Gem::LoadError
68
+ msg = "config.gem is deprecated, and you tried to activate the '#{name}' gem (#{options.inspect}) using it.\n"
69
+
70
+ if File.exist?("#{Rails.root}/Gemfile")
71
+ msg << "Please add '#{name}' to your Gemfile."
72
+ else
73
+ msg << "Please update your application to use bundler."
74
+ end
75
+ ActiveSupport::Deprecation.warn(msg, caller)
76
+ exit
77
+ end
51
78
  end
52
79
  end
53
- end
80
+ end
@@ -218,11 +218,11 @@ module Rails
218
218
  puts "Usage: rails #{command} GENERATOR [args] [options]"
219
219
  puts
220
220
  puts "General options:"
221
- puts " -h, [--help] # Print generators options and usage"
221
+ puts " -h, [--help] # Print generator's options and usage"
222
222
  puts " -p, [--pretend] # Run but do not make any changes"
223
223
  puts " -f, [--force] # Overwrite files that already exist"
224
224
  puts " -s, [--skip] # Skip files that already exist"
225
- puts " -q, [--quiet] # Supress status output"
225
+ puts " -q, [--quiet] # Suppress status output"
226
226
  puts
227
227
  puts "Please choose a generator below."
228
228
  puts
@@ -242,7 +242,7 @@ module Rails
242
242
  def rake(command, options={})
243
243
  log :rake, command
244
244
  env = options[:env] || 'development'
245
- sudo = options[:sudo] && Config::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
245
+ sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
246
246
  in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) }
247
247
  end
248
248
 
@@ -275,7 +275,7 @@ module Rails
275
275
  #
276
276
  def route(routing_code)
277
277
  log :route, routing_code
278
- sentinel = /\.routes\.draw do(\s*\|map\|)?\s*$/
278
+ sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
279
279
 
280
280
  in_root do
281
281
  inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
@@ -309,7 +309,7 @@ module Rails
309
309
  # Add an extension to the given name based on the platform.
310
310
  #
311
311
  def extify(name)
312
- if Config::CONFIG['host_os'] =~ /mswin|mingw/
312
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
313
313
  "#{name}.bat"
314
314
  else
315
315
  name
@@ -9,16 +9,16 @@ module Rails
9
9
  # For example:
10
10
  #
11
11
  # ActiveRecord::Generators::ActiveModel.find(Foo, "params[:id]")
12
- # #=> "Foo.find(params[:id])"
12
+ # # => "Foo.find(params[:id])"
13
13
  #
14
14
  # Datamapper::Generators::ActiveModel.find(Foo, "params[:id]")
15
- # #=> "Foo.get(params[:id])"
15
+ # # => "Foo.get(params[:id])"
16
16
  #
17
17
  # On initialization, the ActiveModel accepts the instance name that will
18
18
  # receive the calls:
19
19
  #
20
20
  # builder = ActiveRecord::Generators::ActiveModel.new "@foo"
21
- # builder.save #=> "@foo.save"
21
+ # builder.save # => "@foo.save"
22
22
  #
23
23
  # The only exception in ActiveModel for ActiveRecord is the use of self.build
24
24
  # instead of self.new.
@@ -81,7 +81,7 @@ module Rails
81
81
  # guessed based on class invokes hook_for, as noticed in the example above.
82
82
  # This can be customized with two options: :base and :as.
83
83
  #
84
- # Let's suppose you are creating a generator that needs to invoke the
84
+ # Let's suppose you are creating a generator that needs to invoke the
85
85
  # controller generator from test unit. Your first attempt is:
86
86
  #
87
87
  # class AwesomeGenerator < Rails::Generators::Base
@@ -216,7 +216,7 @@ module Rails
216
216
 
217
217
  empty_directory '.'
218
218
  set_default_accessors!
219
- FileUtils.cd(destination_root)
219
+ FileUtils.cd(destination_root) unless options[:pretend]
220
220
  end
221
221
 
222
222
  def create_root_files
@@ -356,8 +356,13 @@ module Rails
356
356
  @app_name ||= File.basename(destination_root)
357
357
  end
358
358
 
359
+ def defined_app_const_base
360
+ Rails.respond_to?(:application) && defined?(Rails::Application) &&
361
+ Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "")
362
+ end
363
+
359
364
  def app_const_base
360
- @app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize
365
+ @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize
361
366
  end
362
367
 
363
368
  def app_const
@@ -389,6 +394,7 @@ module Rails
389
394
  when "postgresql" then "pg"
390
395
  when "sqlite3" then "sqlite3-ruby"
391
396
  when "frontbase" then "ruby-frontbase"
397
+ when "mysql" then "mysql2"
392
398
  else options[:database]
393
399
  end
394
400
  end
@@ -410,7 +416,7 @@ module Rails
410
416
  "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
411
417
  "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
412
418
  "/opt/lampp/var/mysql/mysql.sock" # xampp for linux
413
- ].find { |f| File.exist?(f) } unless Config::CONFIG['host_os'] =~ /mswin|mingw/
419
+ ].find { |f| File.exist?(f) } unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
414
420
  end
415
421
 
416
422
  def empty_directory_with_gitkeep(destination, config = {})
@@ -13,7 +13,7 @@ gem 'rails', '<%= Rails::VERSION::STRING %>'
13
13
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
14
14
  <%- end -%>
15
15
 
16
- <% unless options[:skip_activerecord] -%>
16
+ <% unless options[:skip_active_record] -%>
17
17
  gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= require_for_database %>'<% end %>
18
18
  <% end -%>
19
19
 
@@ -28,7 +28,7 @@ gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= req
28
28
 
29
29
  # Bundle the extra gems:
30
30
  # gem 'bj'
31
- # gem 'nokogiri', '1.4.1'
31
+ # gem 'nokogiri'
32
32
  # gem 'sqlite3-ruby', :require => 'sqlite3'
33
33
  # gem 'aws-s3', :require => 'aws/s3'
34
34
 
@@ -1,21 +1,12 @@
1
1
  # MySQL. Versions 4.1 and 5.0 are recommended.
2
2
  #
3
3
  # Install the MySQL driver:
4
- # gem install mysql
5
- # On Mac OS X:
6
- # sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
7
- # On Mac OS X Leopard:
8
- # sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
9
- # This sets the ARCHFLAGS environment variable to your native architecture
10
- # On Windows:
11
- # gem install mysql
12
- # Choose the win32 build.
13
- # Install MySQL and put its /bin directory on your path.
4
+ # gem install mysql2
14
5
  #
15
6
  # And be sure to use new-style password hashing:
16
7
  # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
17
8
  development:
18
- adapter: mysql
9
+ adapter: mysql2
19
10
  encoding: utf8
20
11
  reconnect: false
21
12
  database: <%= app_name %>_development
@@ -32,7 +23,7 @@ development:
32
23
  # re-generated from your development database when you run "rake".
33
24
  # Do not set this db to the same as development or production.
34
25
  test:
35
- adapter: mysql
26
+ adapter: mysql2
36
27
  encoding: utf8
37
28
  reconnect: false
38
29
  database: <%= app_name %>_test
@@ -46,7 +37,7 @@ test:
46
37
  <% end -%>
47
38
 
48
39
  production:
49
- adapter: mysql
40
+ adapter: mysql2
50
41
  encoding: utf8
51
42
  reconnect: false
52
43
  database: <%= app_name %>_production
@@ -4,7 +4,7 @@
4
4
  # http://rubyforge.org/projects/ruby-oci8/
5
5
  #
6
6
  # Specify your database using any valid connection syntax, such as a
7
- # tnsnames.ora service name, or a SQL connect url string of the form:
7
+ # tnsnames.ora service name, or an SQL connect string of the form:
8
8
  #
9
9
  # //host:[port][/service name]
10
10
  #
@@ -19,4 +19,8 @@
19
19
 
20
20
  # Print deprecation notices to the Rails logger
21
21
  config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
22
25
  end
26
+
@@ -16,12 +16,12 @@
16
16
  # Sample resource route with options:
17
17
  # resources :products do
18
18
  # member do
19
- # get :short
20
- # post :toggle
19
+ # get 'short'
20
+ # post 'toggle'
21
21
  # end
22
22
  #
23
23
  # collection do
24
- # get :sold
24
+ # get 'sold'
25
25
  # end
26
26
  # end
27
27
 
@@ -35,7 +35,7 @@
35
35
  # resources :products do
36
36
  # resources :comments
37
37
  # resources :sales do
38
- # get :recent, :on => :collection
38
+ # get 'recent', :on => :collection
39
39
  # end
40
40
  # end
41
41
 
@@ -151,19 +151,6 @@
151
151
  }
152
152
 
153
153
 
154
- #search {
155
- margin: 0;
156
- padding-top: 10px;
157
- padding-bottom: 10px;
158
- font-size: 11px;
159
- }
160
- #search input {
161
- font-size: 11px;
162
- margin: 2px;
163
- }
164
- #search-text {width: 170px}
165
-
166
-
167
154
  #sidebar ul {
168
155
  margin-left: 0;
169
156
  padding-left: 0;
@@ -194,16 +181,6 @@
194
181
  info.innerHTML = xhr.responseText;
195
182
  info.style.display = 'block'
196
183
  }
197
-
198
- function prepend() {
199
- search = document.getElementById('search-text');
200
- text = search.value;
201
- search.value = 'site:rubyonrails.org ' + text;
202
- }
203
-
204
- window.onload = function() {
205
- document.getElementById('search-text').value = '';
206
- }
207
184
  </script>
208
185
  </head>
209
186
  <body>
@@ -150,7 +150,7 @@ var Effect = {
150
150
  toggle: function(element, effect, options) {
151
151
  element = $(element);
152
152
  effect = (effect || 'appear').toLowerCase();
153
-
153
+
154
154
  return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
155
155
  queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
156
156
  }, options || {}));
@@ -1,6 +1,6 @@
1
1
  Description:
2
- Stubs out a new generator at lib/generators. Pass the generator name, either
3
- CamelCased or under_scored, as an argument.
2
+ Stubs out a new generator at lib/generators. Pass the generator name as an argument,
3
+ either CamelCased or snake_cased.
4
4
 
5
5
  Example:
6
6
  `rails generate generator Awesome`
@@ -8,4 +8,5 @@ Example:
8
8
  creates a standard awesome generator:
9
9
  lib/generators/awesome/
10
10
  lib/generators/awesome/awesome_generator.rb
11
+ lib/generators/awesome/USAGE
11
12
  lib/generators/awesome/templates/
@@ -18,12 +18,12 @@ Example:
18
18
  This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with
19
19
  this in the Up migration:
20
20
 
21
- add_column :posts, :title, :string
22
- add_column :posts, :body, :text
21
+ add_column :posts, :title, :string
22
+ add_column :posts, :body, :text
23
23
  add_column :posts, :published, :boolean
24
24
 
25
25
  And this in the Down migration:
26
26
 
27
- remove_column :posts, :published
28
- remove_column :posts, :body
27
+ remove_column :posts, :published
28
+ remove_column :posts, :body
29
29
  remove_column :posts, :title
@@ -1,6 +1,6 @@
1
1
  Description:
2
2
  Stubs out a new plugin at vendor/plugins. Pass the plugin name, either
3
- CamelCased or under_scored, as an argument.
3
+ CamelCased or under_scored, as an argument.
4
4
 
5
5
  Example:
6
6
  `rails generate plugin BrowserFilters`