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.
- data/CHANGELOG +47 -1
- data/guides/rails_guides/generator.rb +5 -4
- data/guides/source/action_controller_overview.textile +26 -0
- data/guides/source/active_support_core_extensions.textile +10 -0
- data/guides/source/association_basics.textile +2 -2
- data/guides/source/caching_with_rails.textile +30 -1
- data/guides/source/configuring.textile +40 -45
- data/guides/source/contributing_to_ruby_on_rails.textile +20 -11
- data/guides/source/generators.textile +23 -24
- data/guides/source/getting_started.textile +4 -4
- data/guides/source/layout.html.erb +1 -1
- data/guides/source/migrations.textile +1 -1
- data/guides/source/performance_testing.textile +159 -84
- data/guides/source/rails_on_rack.textile +0 -6
- data/guides/source/security.textile +5 -5
- data/guides/source/testing.textile +3 -3
- data/lib/rails/application.rb +12 -7
- data/lib/rails/application/bootstrap.rb +2 -1
- data/lib/rails/application/configuration.rb +1 -1
- data/lib/rails/commands.rb +2 -1
- data/lib/rails/commands/benchmarker.rb +28 -19
- data/lib/rails/commands/dbconsole.rb +1 -1
- data/lib/rails/commands/profiler.rb +27 -43
- data/lib/rails/commands/runner.rb +9 -15
- data/lib/rails/commands/server.rb +2 -1
- data/lib/rails/engine.rb +9 -2
- data/lib/rails/engine/configuration.rb +1 -0
- data/lib/rails/generators.rb +2 -2
- data/lib/rails/generators/actions.rb +1 -1
- data/lib/rails/generators/app_base.rb +24 -16
- data/lib/rails/generators/base.rb +2 -2
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +7 -6
- data/lib/rails/generators/named_base.rb +2 -0
- data/lib/rails/generators/rails/app/app_generator.rb +15 -6
- data/lib/rails/generators/rails/app/templates/Gemfile +2 -1
- data/lib/rails/generators/rails/app/templates/README +10 -5
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +5 -2
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb +3 -12
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +4 -1
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +3 -0
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +3 -0
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +4 -0
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +4 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +5 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +4 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +3 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +0 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/gitignore +1 -0
- data/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +4 -1
- data/lib/rails/generators/rails/assets/USAGE +3 -3
- data/lib/rails/generators/rails/assets/assets_generator.rb +4 -4
- data/lib/rails/generators/rails/controller/templates/controller.rb +1 -1
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -2
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +1 -1
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +3 -3
- data/lib/rails/generators/test_unit/performance/templates/performance_test.rb +4 -1
- data/lib/rails/rack.rb +4 -4
- data/lib/rails/rack/content_length.rb +38 -0
- data/lib/rails/railtie.rb +1 -0
- data/lib/rails/tasks/framework.rake +2 -7
- data/lib/rails/tasks/routes.rake +1 -1
- data/lib/rails/version.rb +1 -1
- metadata +6 -6
- 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
|
121
|
-
# to use any test framework,
|
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
|
#
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<table>
|
4
4
|
<tr>
|
5
|
-
<%
|
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
|
-
<%
|
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>
|
@@ -13,12 +13,13 @@ module Rails
|
|
13
13
|
|
14
14
|
def field_type
|
15
15
|
@field_type ||= case type
|
16
|
-
when :integer
|
17
|
-
when :
|
18
|
-
when :
|
19
|
-
when :
|
20
|
-
when :
|
21
|
-
when :
|
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
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
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
|
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, :
|
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.
|
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
|
-
//
|
2
|
-
//
|
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
|
-
*
|
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
|
-
<%
|
3
|
+
<% if include_all_railties? -%>
|
4
4
|
require 'rails/all'
|
5
5
|
<% else -%>
|
6
6
|
# Pick the frameworks you want:
|
7
|
-
|
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
|
@@ -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,8 +1,11 @@
|
|
1
1
|
# MySQL. Versions 4.1 and 5.0 are recommended.
|
2
|
-
#
|
3
|
-
# Install the
|
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:
|
@@ -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
|
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
|
7
|
-
ActionController::Base.wrap_parameters :format
|
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, "'
|
7
|
+
# Mayor.create(<%= key_value :name, "'Emanuel'" %>, <%= key_value :city, "cities.first" %>)
|
@@ -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
|
2
|
+
Stubs out new asset placeholders. Pass the asset name, either CamelCased
|
3
3
|
or under_scored.
|
4
4
|
|
5
|
-
To create
|
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
|
-
|
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
|
5
|
-
class_option :stylesheets, :type => :boolean, :desc => "Generate
|
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
|
8
|
-
class_option :stylesheet_engine, :desc => "Engine for
|
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?
|
@@ -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, :
|
213
|
+
public_task :apply_rails_template, :run_bundle
|
213
214
|
|
214
215
|
protected
|
215
216
|
|