railties 3.1.0.beta1 → 3.1.0.rc1

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 +47 -1
  2. data/guides/rails_guides/generator.rb +5 -4
  3. data/guides/source/action_controller_overview.textile +26 -0
  4. data/guides/source/active_support_core_extensions.textile +10 -0
  5. data/guides/source/association_basics.textile +2 -2
  6. data/guides/source/caching_with_rails.textile +30 -1
  7. data/guides/source/configuring.textile +40 -45
  8. data/guides/source/contributing_to_ruby_on_rails.textile +20 -11
  9. data/guides/source/generators.textile +23 -24
  10. data/guides/source/getting_started.textile +4 -4
  11. data/guides/source/layout.html.erb +1 -1
  12. data/guides/source/migrations.textile +1 -1
  13. data/guides/source/performance_testing.textile +159 -84
  14. data/guides/source/rails_on_rack.textile +0 -6
  15. data/guides/source/security.textile +5 -5
  16. data/guides/source/testing.textile +3 -3
  17. data/lib/rails/application.rb +12 -7
  18. data/lib/rails/application/bootstrap.rb +2 -1
  19. data/lib/rails/application/configuration.rb +1 -1
  20. data/lib/rails/commands.rb +2 -1
  21. data/lib/rails/commands/benchmarker.rb +28 -19
  22. data/lib/rails/commands/dbconsole.rb +1 -1
  23. data/lib/rails/commands/profiler.rb +27 -43
  24. data/lib/rails/commands/runner.rb +9 -15
  25. data/lib/rails/commands/server.rb +2 -1
  26. data/lib/rails/engine.rb +9 -2
  27. data/lib/rails/engine/configuration.rb +1 -0
  28. data/lib/rails/generators.rb +2 -2
  29. data/lib/rails/generators/actions.rb +1 -1
  30. data/lib/rails/generators/app_base.rb +24 -16
  31. data/lib/rails/generators/base.rb +2 -2
  32. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +1 -1
  33. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
  34. data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -1
  35. data/lib/rails/generators/generated_attribute.rb +7 -6
  36. data/lib/rails/generators/named_base.rb +2 -0
  37. data/lib/rails/generators/rails/app/app_generator.rb +15 -6
  38. data/lib/rails/generators/rails/app/templates/Gemfile +2 -1
  39. data/lib/rails/generators/rails/app/templates/README +10 -5
  40. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +5 -2
  41. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -1
  42. data/lib/rails/generators/rails/app/templates/config/application.rb +3 -12
  43. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +4 -1
  44. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +3 -0
  45. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +3 -0
  46. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +4 -0
  47. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +4 -1
  48. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +5 -2
  49. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +4 -0
  50. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +3 -0
  51. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +0 -1
  52. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
  53. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
  54. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
  55. data/lib/rails/generators/rails/app/templates/gitignore +1 -0
  56. data/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +4 -1
  57. data/lib/rails/generators/rails/assets/USAGE +3 -3
  58. data/lib/rails/generators/rails/assets/assets_generator.rb +4 -4
  59. data/lib/rails/generators/rails/controller/templates/controller.rb +1 -1
  60. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +2 -1
  61. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -2
  62. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +1 -1
  63. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +1 -1
  64. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +3 -3
  65. data/lib/rails/generators/test_unit/performance/templates/performance_test.rb +4 -1
  66. data/lib/rails/rack.rb +4 -4
  67. data/lib/rails/rack/content_length.rb +38 -0
  68. data/lib/rails/railtie.rb +1 -0
  69. data/lib/rails/tasks/framework.rake +2 -7
  70. data/lib/rails/tasks/routes.rake +1 -1
  71. data/lib/rails/version.rb +1 -1
  72. metadata +6 -6
  73. data/lib/rails/rack/static.rb +0 -5
@@ -117,8 +117,8 @@ module Rails
117
117
  #
118
118
  # ==== Switches
119
119
  #
120
- # All hooks come with switches for user interface. If the user don't want
121
- # to use any test framework, he can do:
120
+ # All hooks come with switches for user interface. If you do not want
121
+ # to use any test framework, you can do:
122
122
  #
123
123
  # rails generate controller Account --skip-test-framework
124
124
  #
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  <%% end %>
13
13
 
14
- <% for attribute in attributes -%>
14
+ <% attributes.each do |attribute| -%>
15
15
  <div class="field">
16
16
  <%%= f.label :<%= attribute.name %> %><br />
17
17
  <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <table>
4
4
  <tr>
5
- <% for attribute in attributes -%>
5
+ <% attributes.each do |attribute| -%>
6
6
  <th><%= attribute.human_name %></th>
7
7
  <% end -%>
8
8
  <th></th>
@@ -12,7 +12,7 @@
12
12
 
13
13
  <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
14
  <tr>
15
- <% for attribute in attributes -%>
15
+ <% attributes.each do |attribute| -%>
16
16
  <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
17
  <% end -%>
18
18
  <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
@@ -1,6 +1,6 @@
1
1
  <p id="notice"><%%= notice %></p>
2
2
 
3
- <% for attribute in attributes -%>
3
+ <% attributes.each do |attribute| -%>
4
4
  <p>
5
5
  <b><%= attribute.human_name %>:</b>
6
6
  <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
@@ -13,12 +13,13 @@ module Rails
13
13
 
14
14
  def field_type
15
15
  @field_type ||= case type
16
- when :integer, :float, :decimal then :text_field
17
- when :time then :time_select
18
- when :datetime, :timestamp then :datetime_select
19
- when :date then :date_select
20
- when :text then :text_area
21
- when :boolean then :check_box
16
+ when :integer then :number_field
17
+ when :float, :decimal then :text_field
18
+ when :time then :time_select
19
+ when :datetime, :timestamp then :datetime_select
20
+ when :date then :date_select
21
+ when :text then :text_area
22
+ when :boolean then :check_box
22
23
  else
23
24
  :text_field
24
25
  end
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext/module/introspection'
1
2
  require 'rails/generators/base'
2
3
  require 'rails/generators/generated_attribute'
3
4
 
@@ -12,6 +13,7 @@ module Rails
12
13
  :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
13
14
 
14
15
  def initialize(args, *options) #:nodoc:
16
+ @inside_template = nil
15
17
  # Unfreeze name in case it's given as a frozen string
16
18
  args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
17
19
  super
@@ -9,11 +9,20 @@ module Rails
9
9
  @options = generator.options
10
10
  end
11
11
 
12
- private
12
+ private
13
+ %w(template copy_file directory empty_directory inside
14
+ empty_directory_with_gitkeep create_file chmod shebang).each do |method|
15
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
16
+ def #{method}(*args, &block)
17
+ @generator.send(:#{method}, *args, &block)
18
+ end
19
+ RUBY
20
+ end
13
21
 
14
- def method_missing(meth, *args, &block)
15
- @generator.send(meth, *args, &block)
16
- end
22
+ # TODO: Remove once this is fully in place
23
+ def method_missing(meth, *args, &block)
24
+ @generator.send(meth, *args, &block)
25
+ end
17
26
  end
18
27
 
19
28
  # The application builder allows you to override elements of the application
@@ -21,7 +30,7 @@ module Rails
21
30
  # generator.
22
31
  #
23
32
  # This allows you to override entire operations, like the creation of the
24
- # Gemfile, README, or javascript files, without needing to know exactly
33
+ # Gemfile, README, or JavaScript files, without needing to know exactly
25
34
  # what those operations do so you can create another template action.
26
35
  class AppBuilder
27
36
  def rakefile
@@ -215,7 +224,7 @@ module Rails
215
224
  build(:leftovers)
216
225
  end
217
226
 
218
- public_task :apply_rails_template, :bundle_if_dev_or_edge
227
+ public_task :apply_rails_template, :run_bundle
219
228
 
220
229
  protected
221
230
 
@@ -4,6 +4,7 @@ source 'http://rubygems.org'
4
4
 
5
5
  <%= database_gemfile_entry -%>
6
6
 
7
+ <%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) && JRUBY_VERSION < "1.6" -%>
7
8
  # Asset template engines
8
9
  <%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
9
10
  gem 'sass'
@@ -21,4 +22,4 @@ gem 'uglifier'
21
22
  # To use debugger
22
23
  # <%= gem_for_ruby_debugger %>
23
24
 
24
- <%= gem_for_turn -%>
25
+ <%= gem_for_turn -%>
@@ -156,6 +156,10 @@ PostgreSQL and SQLite 3.
156
156
  The default directory structure of a generated Ruby on Rails application:
157
157
 
158
158
  |-- app
159
+ | |-- assets
160
+ | |-- images
161
+ | |-- javascripts
162
+ | `-- stylesheets
159
163
  | |-- controllers
160
164
  | |-- helpers
161
165
  | |-- mailers
@@ -172,9 +176,6 @@ The default directory structure of a generated Ruby on Rails application:
172
176
  | `-- tasks
173
177
  |-- log
174
178
  |-- public
175
- | |-- images
176
- | |-- javascripts
177
- | `-- stylesheets
178
179
  |-- script
179
180
  |-- test
180
181
  | |-- fixtures
@@ -188,11 +189,16 @@ The default directory structure of a generated Ruby on Rails application:
188
189
  | |-- sessions
189
190
  | `-- sockets
190
191
  `-- vendor
192
+ |-- assets
193
+ `-- stylesheets
191
194
  `-- plugins
192
195
 
193
196
  app
194
197
  Holds all the code that's specific to this particular application.
195
198
 
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
196
202
  app/controllers
197
203
  Holds controllers that should be named like weblogs_controller.rb for
198
204
  automated URL mapping. All controllers should descend from
@@ -237,8 +243,7 @@ lib
237
243
  the load path.
238
244
 
239
245
  public
240
- The directory available for the web server. Contains subdirectories for
241
- images, stylesheets, and javascripts. Also contains the dispatchers and the
246
+ The directory available for the web server. Also contains the dispatchers and the
242
247
  default HTML files. This should be set as the DOCUMENT_ROOT of your web
243
248
  server.
244
249
 
@@ -1,5 +1,8 @@
1
- // FIXME: Tell people that this is a manifest file, real code should go into discrete files
2
- // FIXME: Tell people how Sprockets and CoffeeScript works
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
3
6
  //
4
7
  <% unless options[:skip_javascript] -%>
5
8
  //= require <%= options[:javascript] %>
@@ -1,5 +1,7 @@
1
1
  /*
2
- * FIXME: Introduce SCSS & Sprockets
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
3
5
  *= require_self
4
6
  *= require_tree .
5
7
  */
@@ -1,14 +1,14 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- <% unless options[:skip_active_record] -%>
3
+ <% if include_all_railties? -%>
4
4
  require 'rails/all'
5
5
  <% else -%>
6
6
  # Pick the frameworks you want:
7
- # require "active_record/railtie"
7
+ <%= comment_if :skip_active_record %> require "active_record/railtie"
8
8
  require "action_controller/railtie"
9
9
  require "action_mailer/railtie"
10
10
  require "active_resource/railtie"
11
- require "rails/test_unit/railtie"
11
+ <%= comment_if :skip_test_unit %> require "rails/test_unit/railtie"
12
12
  <% end -%>
13
13
 
14
14
  # If you have a Gemfile, require the gems listed there, including any gems
@@ -50,21 +50,12 @@ module <%= app_const_base %>
50
50
  # config.action_view.javascript_expansions[:defaults] = %w(prototype prototype_ujs)
51
51
  <% end -%>
52
52
 
53
- <% if options[:skip_test_unit] -%>
54
- config.generators.test_framework = false
55
- <% end -%>
56
-
57
53
  # Configure the default encoding used in templates for Ruby 1.9.
58
54
  config.encoding = "utf-8"
59
55
 
60
56
  # Configure sensitive parameters which will be filtered from the log file.
61
57
  config.filter_parameters += [:password]
62
58
 
63
- <% unless options[:skip_active_record] -%>
64
- # Enable IdentityMap for Active Record, to disable set to false or remove the line below.
65
- config.active_record.identity_map = true
66
- <% end -%>
67
-
68
59
  # Enable the asset pipeline
69
60
  config.assets.enabled = true
70
61
  end
@@ -2,7 +2,10 @@
2
2
  #
3
3
  # Get the bindings:
4
4
  # gem install ruby-frontbase
5
-
5
+ #
6
+ # Configure Using Gemfile
7
+ # gem 'ruby-frontbase'
8
+ #
6
9
  development:
7
10
  adapter: frontbase
8
11
  host: localhost
@@ -28,6 +28,9 @@
28
28
  # On Windows:
29
29
  # Issue the command: gem install ibm_db
30
30
  #
31
+ # Configure Using Gemfile
32
+ # gem 'ibm_db'
33
+ #
31
34
  # For more details on the installation and the connection parameters below,
32
35
  # please refer to the latest documents at http://rubyforge.org/docman/?group_id=2361
33
36
 
@@ -3,6 +3,9 @@
3
3
  # Install the MySQL driver:
4
4
  # gem install activerecord-jdbcmysql-adapter
5
5
  #
6
+ # Configure Using Gemfile
7
+ # gem 'activerecord-jdbcmysql-adapter'
8
+ #
6
9
  # And be sure to use new-style password hashing:
7
10
  # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
8
11
  development:
@@ -8,6 +8,10 @@
8
8
  # gem install pg
9
9
  # Choose the win32 build.
10
10
  # Install PostgreSQL and put its /bin directory on your path.
11
+ #
12
+ # Configure Using Gemfile
13
+ # gem 'activerecord-jdbcpostgresql-adapter'
14
+
11
15
  development:
12
16
  adapter: jdbcpostgresql
13
17
  encoding: unicode
@@ -1,6 +1,9 @@
1
1
  # SQLite version 3.x
2
2
  # gem 'activerecord-jdbcsqlite3-adapter'
3
-
3
+ #
4
+ # Configure Using Gemfile
5
+ # gem 'activerecord-jdbcsqlite3-adapter'
6
+ #
4
7
  development:
5
8
  adapter: jdbcsqlite3
6
9
  database: db/development.sqlite3
@@ -1,8 +1,11 @@
1
1
  # MySQL. Versions 4.1 and 5.0 are recommended.
2
- #
3
- # Install the MySQL driver:
2
+ #
3
+ # Install the MYSQL driver
4
4
  # gem install mysql2
5
5
  #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
6
9
  # And be sure to use new-style password hashing:
7
10
  # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
8
11
  development:
@@ -8,6 +8,10 @@
8
8
  # gem install pg
9
9
  # Choose the win32 build.
10
10
  # Install PostgreSQL and put its /bin directory on your path.
11
+ #
12
+ # Configure Using Gemfile
13
+ # gem 'pg'
14
+ #
11
15
  development:
12
16
  adapter: postgresql
13
17
  encoding: unicode
@@ -1,5 +1,8 @@
1
1
  # SQLite version 3.x
2
2
  # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
3
6
  development:
4
7
  adapter: sqlite3
5
8
  database: db/development.sqlite3
@@ -22,4 +22,3 @@
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
  end
25
-
@@ -31,7 +31,7 @@
31
31
  # Use a different cache store in production
32
32
  # config.cache_store = :mem_cache_store
33
33
 
34
- # Enable serving of images, stylesheets, and javascripts from an asset server
34
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
35
35
  # config.action_controller.asset_host = "http://assets.example.com"
36
36
 
37
37
  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
@@ -3,8 +3,8 @@
3
3
  # This file contains the settings for ActionController::ParametersWrapper
4
4
  # which will be enabled by default in the upcoming version of Ruby on Rails.
5
5
 
6
- # Enable parameter wrapping for JSON. You can disable this by set :format to empty array.
7
- ActionController::Base.wrap_parameters :format => [:json]
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActionController::Base.wrap_parameters <%= key_value :format, "[:json]" %>
8
8
 
9
9
  # Disable root element in JSON by default.
10
10
  if defined?(ActiveRecord)
@@ -4,4 +4,4 @@
4
4
  # Examples:
5
5
  #
6
6
  # cities = City.create([{ <%= key_value :name, "'Chicago'" %> }, { <%= key_value :name, "'Copenhagen'" %> }])
7
- # Mayor.create(<%= key_value :name, "'Daley'" %>, <%= key_value :city, "cities.first" %>)
7
+ # Mayor.create(<%= key_value :name, "'Emanuel'" %>, <%= key_value :city, "cities.first" %>)
@@ -2,3 +2,4 @@
2
2
  db/*.sqlite3
3
3
  log/*.log
4
4
  tmp/
5
+ .sass-cache/
@@ -1,8 +1,11 @@
1
1
  require 'test_helper'
2
2
  require 'rails/performance_test_help'
3
3
 
4
- # Profiling results for each test method are written to tmp/performance.
5
4
  class BrowsingTest < ActionDispatch::PerformanceTest
5
+ # Refer to the documentation for all available options
6
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
+ # :output => 'tmp/performance', :formats => [:flat] }
8
+
6
9
  def test_homepage
7
10
  get '/'
8
11
  end
@@ -1,8 +1,8 @@
1
1
  Description:
2
- Stubs out a new asset placeholders. Pass the asset name, either CamelCased
2
+ Stubs out new asset placeholders. Pass the asset name, either CamelCased
3
3
  or under_scored.
4
4
 
5
- To create assets within a folder, specify the assets name as a
5
+ To create an asset within a folder, specify the asset's name as a
6
6
  path like 'parent/name'.
7
7
 
8
8
  This generates a JavaScript stub in app/assets/javascripts and a stylesheet
@@ -15,6 +15,6 @@ Example:
15
15
  `rails generate assets posts`
16
16
 
17
17
  Posts assets.
18
- Javascript: app/assets/javascripts/posts.js
18
+ JavaScript: app/assets/javascripts/posts.js
19
19
  Stylesheet: app/assets/stylesheets/posts.css
20
20
 
@@ -1,11 +1,11 @@
1
1
  module Rails
2
2
  module Generators
3
3
  class AssetsGenerator < NamedBase
4
- class_option :javascripts, :type => :boolean, :desc => "Generate javascripts"
5
- class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets"
4
+ class_option :javascripts, :type => :boolean, :desc => "Generate JavaScripts"
5
+ class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets"
6
6
 
7
- class_option :javascript_engine, :desc => "Engine for javascripts"
8
- class_option :stylesheet_engine, :desc => "Engine for stylesheets"
7
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
8
+ class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
9
9
 
10
10
  def create_javascript_files
11
11
  return unless options.javascripts?
@@ -1,6 +1,6 @@
1
1
  <% module_namespacing do -%>
2
2
  class <%= class_name %>Controller < ApplicationController
3
- <% for action in actions -%>
3
+ <% actions.each do |action| -%>
4
4
  def <%= action %>
5
5
  end
6
6
 
@@ -75,6 +75,7 @@ task :default => :test
75
75
  def generate_test_dummy(force = false)
76
76
  opts = (options || {}).slice(*PASSTHROUGH_OPTIONS)
77
77
  opts[:force] = force
78
+ opts[:skip_bundle] = true
78
79
 
79
80
  invoke Rails::Generators::AppGenerator,
80
81
  [ File.expand_path(dummy_path, destination_root) ], opts
@@ -209,7 +210,7 @@ task :default => :test
209
210
  build(:leftovers)
210
211
  end
211
212
 
212
- public_task :apply_rails_template, :bundle_if_dev_or_edge
213
+ public_task :apply_rails_template, :run_bundle
213
214
 
214
215
  protected
215
216