rails 4.2.0.beta1 → 4.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/guides/rails_guides/markdown.rb +6 -1
- data/guides/source/2_2_release_notes.md +1 -1
- data/guides/source/2_3_release_notes.md +1 -1
- data/guides/source/3_0_release_notes.md +2 -2
- data/guides/source/3_1_release_notes.md +4 -1
- data/guides/source/3_2_release_notes.md +4 -1
- data/guides/source/4_0_release_notes.md +4 -1
- data/guides/source/4_1_release_notes.md +4 -4
- data/guides/source/4_2_release_notes.md +272 -45
- data/guides/source/action_controller_overview.md +3 -3
- data/guides/source/action_mailer_basics.md +28 -4
- data/guides/source/action_view_overview.md +11 -11
- data/guides/source/active_job_basics.md +99 -63
- data/guides/source/active_record_postgresql.md +2 -1
- data/guides/source/active_record_querying.md +7 -9
- data/guides/source/active_support_core_extensions.md +48 -2
- data/guides/source/asset_pipeline.md +200 -18
- data/guides/source/association_basics.md +8 -8
- data/guides/source/caching_with_rails.md +1 -1
- data/guides/source/command_line.md +1 -1
- data/guides/source/configuring.md +7 -7
- data/guides/source/contributing_to_ruby_on_rails.md +17 -0
- data/guides/source/debugging_rails_applications.md +2 -2
- data/guides/source/development_dependencies_install.md +41 -43
- data/guides/source/form_helpers.md +17 -17
- data/guides/source/generators.md +6 -2
- data/guides/source/getting_started.md +1 -1
- data/guides/source/i18n.md +16 -0
- data/guides/source/initialization.md +0 -2
- data/guides/source/layouts_and_rendering.md +2 -1
- data/guides/source/maintenance_policy.md +6 -3
- data/guides/source/nested_model_forms.md +4 -1
- data/guides/source/routing.md +1 -1
- data/guides/source/testing.md +2 -2
- data/guides/source/upgrading_ruby_on_rails.md +94 -23
- metadata +18 -18
data/guides/source/testing.md
CHANGED
@@ -99,7 +99,7 @@ one:
|
|
99
99
|
Note: For associations to reference one another by name, you cannot specify the `id:`
|
100
100
|
attribute on the fixtures. Rails will auto assign a primary key to be consistent between
|
101
101
|
runs. If you manually specify an `id:` attribute, this behavior will not work. For more
|
102
|
-
information on this
|
102
|
+
information on this association behavior please read the
|
103
103
|
[fixture api documentation](http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html).
|
104
104
|
|
105
105
|
#### ERB'in It Up
|
@@ -949,7 +949,7 @@ class UserMailerTest < ActionMailer::TestCase
|
|
949
949
|
test "invite" do
|
950
950
|
# Send the email, then test that it got queued
|
951
951
|
email = UserMailer.create_invite('me@example.com',
|
952
|
-
'friend@example.com', Time.now).
|
952
|
+
'friend@example.com', Time.now).deliver_now
|
953
953
|
assert_not ActionMailer::Base.deliveries.empty?
|
954
954
|
|
955
955
|
# Test the body of the sent email contains what we expect it to
|
@@ -8,7 +8,7 @@ This guide provides steps to be followed when you upgrade your applications to a
|
|
8
8
|
General Advice
|
9
9
|
--------------
|
10
10
|
|
11
|
-
Before attempting to upgrade an existing application, you should be sure you have a good reason to upgrade. You need to balance
|
11
|
+
Before attempting to upgrade an existing application, you should be sure you have a good reason to upgrade. You need to balance several factors: the need for new features, the increasing difficulty of finding support for old code, and your available time and skills, to name a few.
|
12
12
|
|
13
13
|
### Test Coverage
|
14
14
|
|
@@ -55,15 +55,88 @@ a [pull request](https://github.com/rails/rails/edit/master/guides/source/upgrad
|
|
55
55
|
|
56
56
|
### Web Console
|
57
57
|
|
58
|
-
|
58
|
+
First, add `gem 'web-console', '~> 2.0'` to the `:development` group in your Gemfile and run `bundle install` (it won't have been included when you upgraded Rails). Once it's been installed, you can simply drop a reference to the console helper (i.e., `<%= console %>`) into any view you want to enable it for. A console will also be provided on any error page you view in your development environment.
|
59
|
+
|
60
|
+
Additionally, you can tell Rails to automatically mount a VT100-compatible console on a predetermined path by setting the appropriate configuration flags in your development config:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# config/environments/development.rb
|
64
|
+
|
65
|
+
config.web_console.automount = true
|
66
|
+
config.web_console.default_mount_path = '/terminal' # Optional, defaults to /console
|
67
|
+
```
|
59
68
|
|
60
69
|
### Responders
|
61
70
|
|
62
|
-
|
71
|
+
`respond_with` and the class-level `respond_to` methods have been extracted to the `responders` gem. To use them, simply add `gem 'responders', '~> 2.0'` to your Gemfile. Calls to `respond_with` and `respond_to` (again, at the class level) will no longer work without having included the `responders` gem in your dependencies:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
# app/controllers/users_controller.rb
|
75
|
+
|
76
|
+
class UsersController < ApplicationController
|
77
|
+
respond_to :html, :json
|
78
|
+
|
79
|
+
def show
|
80
|
+
@user = User.find(params[:id])
|
81
|
+
respond_with @user
|
82
|
+
end
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
Instance-level `respond_to` is unaffected and does not require the additional gem:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# app/controllers/users_controller.rb
|
90
|
+
|
91
|
+
class UsersController < ApplicationController
|
92
|
+
def show
|
93
|
+
@user = User.find(params[:id])
|
94
|
+
respond_to do |format|
|
95
|
+
format.html
|
96
|
+
format.json { render json: @user }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
```
|
101
|
+
|
102
|
+
See [#16526](https://github.com/rails/rails/pull/16526) for more details.
|
63
103
|
|
64
104
|
### Error handling in transaction callbacks
|
65
105
|
|
66
|
-
|
106
|
+
Currently, Active Record suppresses errors raised
|
107
|
+
within `after_rollback` or `after_commit` callbacks and only prints them to
|
108
|
+
the logs. In the next version, these errors will no longer be suppressed.
|
109
|
+
Instead, the errors will propagate normally just like in other Active
|
110
|
+
Record callbacks.
|
111
|
+
|
112
|
+
When you define a `after_rollback` or `after_commit` callback, you
|
113
|
+
will receive a deprecation warning about this upcoming change. When
|
114
|
+
you are ready, you can opt into the new behvaior and remove the
|
115
|
+
deprecation warning by adding following configuration to your
|
116
|
+
`config/application.rb`:
|
117
|
+
|
118
|
+
config.active_record.raise_in_transactional_callbacks = true
|
119
|
+
|
120
|
+
See [#14488](https://github.com/rails/rails/pull/14488) and
|
121
|
+
[#16537](https://github.com/rails/rails/pull/16537) for more details.
|
122
|
+
|
123
|
+
### Ordering of test cases
|
124
|
+
|
125
|
+
In Rails 5.0, test cases will be executed in random order by default. In
|
126
|
+
anticipation of this change, Rails 4.2 introduced a new configuration option
|
127
|
+
`active_support.test_order` for explicitly specifying the test ordering. This
|
128
|
+
allows you to either lock down the current behavior by setting the option to
|
129
|
+
`:sorted`, or opt into the future behavior by setting the option to `:random`.
|
130
|
+
|
131
|
+
If you do not specify a value for this option, a deprecation warning will be
|
132
|
+
emitted. To avoid this, add the following line to your test environment:
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
# config/environments/test.rb
|
136
|
+
Rails.application.configure do
|
137
|
+
config.active_support.test_order = :sorted # or `:random` if you prefer
|
138
|
+
end
|
139
|
+
```
|
67
140
|
|
68
141
|
### Serialized attributes
|
69
142
|
|
@@ -113,15 +186,6 @@ venerable html-scanner approach is now officially being deprecated in favor of
|
|
113
186
|
This means the methods `sanitize`, `sanitize_css`, `strip_tags` and
|
114
187
|
`strip_links` are backed by a new implementation.
|
115
188
|
|
116
|
-
In the next major Rails version `Rails Html Sanitizer` will be the default
|
117
|
-
sanitizer. It already is for new applications.
|
118
|
-
|
119
|
-
Include this in your Gemfile to try it out today:
|
120
|
-
|
121
|
-
```ruby
|
122
|
-
gem 'rails-html-sanitizer'
|
123
|
-
```
|
124
|
-
|
125
189
|
This new sanitizer uses [Loofah](https://github.com/flavorjones/loofah) internally. Loofah in turn uses Nokogiri, which
|
126
190
|
wraps XML parsers written in both C and Java, so sanitization should be faster
|
127
191
|
no matter which Ruby version you run.
|
@@ -136,6 +200,12 @@ Read the [gem's readme](https://github.com/rails/rails-html-sanitizer) for more
|
|
136
200
|
The documentation for `PermitScrubber` and `TargetScrubber` explains how you
|
137
201
|
can gain complete control over when and how elements should be stripped.
|
138
202
|
|
203
|
+
If your application needs to old behaviour include `rails-deprecated_sanitizer` in your Gemfile:
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
gem 'rails-deprecated_sanitizer'
|
207
|
+
```
|
208
|
+
|
139
209
|
### Rails DOM Testing
|
140
210
|
|
141
211
|
TODO: Mention https://github.com/rails/rails/commit/4e97d7585a2f4788b9eed98c6cdaf4bb6f2cf5ce
|
@@ -148,7 +218,7 @@ Upgrading from Rails 4.0 to Rails 4.1
|
|
148
218
|
Or, "whaaat my tests are failing!!!?"
|
149
219
|
|
150
220
|
Cross-site request forgery (CSRF) protection now covers GET requests with
|
151
|
-
JavaScript responses, too.
|
221
|
+
JavaScript responses, too. This prevents a third-party site from referencing
|
152
222
|
your JavaScript URL and attempting to run it to extract sensitive data.
|
153
223
|
|
154
224
|
This means that your functional and integration tests that use
|
@@ -199,8 +269,8 @@ secrets, you need to:
|
|
199
269
|
```
|
200
270
|
|
201
271
|
2. Use your existing `secret_key_base` from the `secret_token.rb` initializer to
|
202
|
-
set the SECRET_KEY_BASE environment variable for whichever users
|
203
|
-
|
272
|
+
set the SECRET_KEY_BASE environment variable for whichever users running the
|
273
|
+
Rails application in production mode. Alternatively, you can simply copy the existing
|
204
274
|
`secret_key_base` from the `secret_token.rb` initializer to `secrets.yml`
|
205
275
|
under the `production` section, replacing '<%= ENV["SECRET_KEY_BASE"] %>'.
|
206
276
|
|
@@ -393,7 +463,7 @@ included in the newly introduced `ActiveRecord::FixtureSet.context_class`, in
|
|
393
463
|
`test_helper.rb`.
|
394
464
|
|
395
465
|
```ruby
|
396
|
-
|
466
|
+
module FixtureFileHelpers
|
397
467
|
def file_sha(path)
|
398
468
|
Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
|
399
469
|
end
|
@@ -403,8 +473,8 @@ ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
|
|
403
473
|
|
404
474
|
### I18n enforcing available locales
|
405
475
|
|
406
|
-
Rails 4.1 now defaults the I18n option `enforce_available_locales` to `true
|
407
|
-
|
476
|
+
Rails 4.1 now defaults the I18n option `enforce_available_locales` to `true`. This
|
477
|
+
means that it will make sure that all locales passed to it must be declared in
|
408
478
|
the `available_locales` list.
|
409
479
|
|
410
480
|
To disable it (and allow I18n to accept *any* locale option) add the following
|
@@ -414,9 +484,10 @@ configuration to your application:
|
|
414
484
|
config.i18n.enforce_available_locales = false
|
415
485
|
```
|
416
486
|
|
417
|
-
Note that this option was added as a security measure, to ensure user input
|
418
|
-
|
419
|
-
to disable this option unless you have a strong reason for
|
487
|
+
Note that this option was added as a security measure, to ensure user input
|
488
|
+
cannot be used as locale information unless it is previously known. Therefore,
|
489
|
+
it's recommended not to disable this option unless you have a strong reason for
|
490
|
+
doing so.
|
420
491
|
|
421
492
|
### Mutator methods called on Relation
|
422
493
|
|
@@ -524,7 +595,7 @@ Using `render :text` may pose a security risk, as the content is sent as
|
|
524
595
|
### PostgreSQL json and hstore datatypes
|
525
596
|
|
526
597
|
Rails 4.1 will map `json` and `hstore` columns to a string-keyed Ruby `Hash`.
|
527
|
-
In earlier versions a `HashWithIndifferentAccess` was used. This means that
|
598
|
+
In earlier versions, a `HashWithIndifferentAccess` was used. This means that
|
528
599
|
symbol access is no longer supported. This is also the case for
|
529
600
|
`store_accessors` based on top of `json` or `hstore` columns. Make sure to use
|
530
601
|
string keys consistently.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.0.
|
4
|
+
version: 4.2.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,112 +16,112 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.0.
|
19
|
+
version: 4.2.0.beta2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.2.0.
|
26
|
+
version: 4.2.0.beta2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.2.0.
|
33
|
+
version: 4.2.0.beta2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.2.0.
|
40
|
+
version: 4.2.0.beta2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionview
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.2.0.
|
47
|
+
version: 4.2.0.beta2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.2.0.
|
54
|
+
version: 4.2.0.beta2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activemodel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4.2.0.
|
61
|
+
version: 4.2.0.beta2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4.2.0.
|
68
|
+
version: 4.2.0.beta2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.2.0.
|
75
|
+
version: 4.2.0.beta2
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.2.0.
|
82
|
+
version: 4.2.0.beta2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: actionmailer
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 4.2.0.
|
89
|
+
version: 4.2.0.beta2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 4.2.0.
|
96
|
+
version: 4.2.0.beta2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activejob
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 4.2.0.
|
103
|
+
version: 4.2.0.beta2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 4.2.0.
|
110
|
+
version: 4.2.0.beta2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: railties
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 4.2.0.
|
117
|
+
version: 4.2.0.beta2
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 4.2.0.
|
124
|
+
version: 4.2.0.beta2
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: bundler
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|