rails 4.2.0 → 4.2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/guides/CHANGELOG.md +82 -0
- data/guides/Rakefile +16 -3
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/bug_report_templates/action_controller_gem.rb +1 -1
- data/guides/bug_report_templates/active_record_gem.rb +1 -1
- data/guides/bug_report_templates/generic_gem.rb +15 -0
- data/guides/bug_report_templates/generic_master.rb +26 -0
- data/guides/rails_guides/levenshtein.rb +0 -2
- data/guides/source/3_1_release_notes.md +1 -1
- data/guides/source/4_2_release_notes.md +27 -0
- data/guides/source/_welcome.html.erb +5 -1
- data/guides/source/action_controller_overview.md +2 -59
- data/guides/source/action_mailer_basics.md +8 -3
- data/guides/source/action_view_overview.md +2 -61
- data/guides/source/active_job_basics.md +27 -6
- data/guides/source/active_record_basics.md +6 -6
- data/guides/source/active_record_querying.md +1 -3
- data/guides/source/active_record_validations.md +3 -2
- data/guides/source/active_support_core_extensions.md +2 -50
- data/guides/source/active_support_instrumentation.md +0 -11
- data/guides/source/api_documentation_guidelines.md +1 -1
- data/guides/source/asset_pipeline.md +7 -63
- data/guides/source/association_basics.md +16 -7
- data/guides/source/{constant_autoloading_and_reloading.md → autoloading_and_reloading_constants.md} +42 -28
- data/guides/source/configuring.md +30 -5
- data/guides/source/contributing_to_ruby_on_rails.md +7 -3
- data/guides/source/documents.yaml +3 -3
- data/guides/source/engines.md +10 -10
- data/guides/source/getting_started.md +33 -32
- data/guides/source/i18n.md +3 -2
- data/guides/source/initialization.md +1 -1
- data/guides/source/layout.html.erb +4 -7
- data/guides/source/layouts_and_rendering.md +8 -9
- data/guides/source/rails_on_rack.md +0 -1
- data/guides/source/routing.md +15 -1
- data/guides/source/security.md +1 -1
- data/guides/source/testing.md +12 -3
- data/guides/source/upgrading_ruby_on_rails.md +35 -3
- data/guides/source/working_with_javascript_in_rails.md +1 -1
- metadata +22 -21
@@ -82,7 +82,6 @@ To use `rackup` instead of Rails' `rails server`, you can put the following insi
|
|
82
82
|
# Rails.root/config.ru
|
83
83
|
require ::File.expand_path('../config/environment', __FILE__)
|
84
84
|
|
85
|
-
use Rails::Rack::Debugger
|
86
85
|
use Rack::ContentLength
|
87
86
|
run Rails.application
|
88
87
|
```
|
data/guides/source/routing.md
CHANGED
@@ -227,7 +227,7 @@ or, for a single case:
|
|
227
227
|
resources :articles, path: '/admin/articles'
|
228
228
|
```
|
229
229
|
|
230
|
-
In each of these cases, the named routes remain the same as if you did not use `scope`. In the last case, the following paths map to `
|
230
|
+
In each of these cases, the named routes remain the same as if you did not use `scope`. In the last case, the following paths map to `ArticlesController`:
|
231
231
|
|
232
232
|
| HTTP Verb | Path | Controller#Action | Named Helper |
|
233
233
|
| --------- | ------------------------ | -------------------- | ---------------------- |
|
@@ -611,6 +611,8 @@ get 'photos/:id', to: 'photos#show', defaults: { format: 'jpg' }
|
|
611
611
|
|
612
612
|
Rails would match `photos/12` to the `show` action of `PhotosController`, and set `params[:format]` to `"jpg"`.
|
613
613
|
|
614
|
+
NOTE: You cannot override defaults via query parameters - this is for security reasons. The only defaults that can be overridden are dynamic segments via substitution in the URL path.
|
615
|
+
|
614
616
|
### Naming Routes
|
615
617
|
|
616
618
|
You can specify a name for any route using the `:as` option:
|
@@ -805,6 +807,18 @@ As long as `Sprockets` responds to `call` and returns a `[status, headers, body]
|
|
805
807
|
|
806
808
|
NOTE: For the curious, `'articles#index'` actually expands out to `ArticlesController.action(:index)`, which returns a valid Rack application.
|
807
809
|
|
810
|
+
If you specify a rack application as the endpoint for a matcher remember that the route will be unchanged in the receiving application. With the following route your rack application should expect the route to be '/admin':
|
811
|
+
|
812
|
+
```ruby
|
813
|
+
match '/admin', to: AdminApp, via: :all
|
814
|
+
```
|
815
|
+
|
816
|
+
If you would prefer to have your rack application receive requests at the root path instead use mount:
|
817
|
+
|
818
|
+
```ruby
|
819
|
+
mount AdminApp, at: '/admin'
|
820
|
+
```
|
821
|
+
|
808
822
|
### Using `root`
|
809
823
|
|
810
824
|
You can specify what Rails should route `'/'` to with the `root` method:
|
data/guides/source/security.md
CHANGED
@@ -699,7 +699,7 @@ The log files on www.attacker.com will read like this:
|
|
699
699
|
GET http://www.attacker.com/_app_session=836c1c25278e5b321d6bea4f19cb57e2
|
700
700
|
```
|
701
701
|
|
702
|
-
You can mitigate these attacks (in the obvious way) by adding the
|
702
|
+
You can mitigate these attacks (in the obvious way) by adding the **httpOnly** flag to cookies, so that document.cookie may not be read by JavaScript. Http only cookies can be used from IE v6.SP1, Firefox v2.0.0.5 and Opera 9.5. Safari is still considering, it ignores the option. But other, older browsers (such as WebTV and IE 5.5 on Mac) can actually cause the page to fail to load. Be warned that cookies [will still be visible using Ajax](https://www.owasp.org/index.php/HTTPOnly#Browsers_Supporting_HttpOnly), though.
|
703
703
|
|
704
704
|
##### Defacement
|
705
705
|
|
data/guides/source/testing.md
CHANGED
@@ -221,7 +221,16 @@ Every test contains one or more assertions. Only when all the assertions are suc
|
|
221
221
|
|
222
222
|
### Maintaining the test database schema
|
223
223
|
|
224
|
-
In order to run your tests, your test database will need to have the current
|
224
|
+
In order to run your tests, your test database will need to have the current
|
225
|
+
structure. The test helper checks whether your test database has any pending
|
226
|
+
migrations. If so, it will try to load your `db/schema.rb` or `db/structure.sql`
|
227
|
+
into the test database. If migrations are still pending, an error will be
|
228
|
+
raised. Usually this indicates that your schema is not fully migrated. Running
|
229
|
+
the migrations against the development database (`bin/rake db:migrate`) will
|
230
|
+
bring the schema up to date.
|
231
|
+
|
232
|
+
NOTE: If existing migrations required modifications, the test database needs to
|
233
|
+
be rebuilt. This can be done by executing `bin/rake db:test:prepare`.
|
225
234
|
|
226
235
|
### Running Tests
|
227
236
|
|
@@ -941,7 +950,7 @@ In order to test that your mailer is working as expected, you can use unit tests
|
|
941
950
|
|
942
951
|
For the purposes of unit testing a mailer, fixtures are used to provide an example of how the output _should_ look. Because these are example emails, and not Active Record data like the other fixtures, they are kept in their own subdirectory apart from the other fixtures. The name of the directory within `test/fixtures` directly corresponds to the name of the mailer. So, for a mailer named `UserMailer`, the fixtures should reside in `test/fixtures/user_mailer` directory.
|
943
952
|
|
944
|
-
|
953
|
+
If you generated your mailer, the generator does not create stub fixtures for the mailers actions. You'll have to create those files yourself as described above.
|
945
954
|
|
946
955
|
#### The Basic Test Case
|
947
956
|
|
@@ -1100,7 +1109,7 @@ within a model:
|
|
1100
1109
|
```ruby
|
1101
1110
|
require 'test_helper'
|
1102
1111
|
|
1103
|
-
class ProductTest <
|
1112
|
+
class ProductTest < ActiveJob::TestCase
|
1104
1113
|
test 'billing job scheduling' do
|
1105
1114
|
assert_enqueued_with(job: BillingJob) do
|
1106
1115
|
product.charge(account)
|
@@ -248,6 +248,22 @@ class Notifier < ActionMailer::Base
|
|
248
248
|
end
|
249
249
|
```
|
250
250
|
|
251
|
+
### Foreign Key Support
|
252
|
+
|
253
|
+
The migration DSL has been expanded to support foreign key definitions. If
|
254
|
+
you've been using the Foreigner gem, you might want to consider removing it.
|
255
|
+
Note that the foreign key support of Rails is a subset of Foreigner. This means
|
256
|
+
that not every Foreigner definition can be fully replaced by it's Rails
|
257
|
+
migration DSL counterpart.
|
258
|
+
|
259
|
+
The migration procedure is as follows:
|
260
|
+
|
261
|
+
1. remove `gem "foreigner"` from the Gemfile.
|
262
|
+
2. run `bundle install`.
|
263
|
+
3. run `bin/rake db:schema:dump`.
|
264
|
+
4. make sure that `db/schema.rb` contains every foreign key definition with
|
265
|
+
the necessary options.
|
266
|
+
|
251
267
|
Upgrading from Rails 4.0 to Rails 4.1
|
252
268
|
-------------------------------------
|
253
269
|
|
@@ -766,7 +782,7 @@ file (in `config/application.rb`):
|
|
766
782
|
```ruby
|
767
783
|
# Require the gems listed in Gemfile, including any gems
|
768
784
|
# you've limited to :test, :development, or :production.
|
769
|
-
Bundler.require(
|
785
|
+
Bundler.require(*Rails.groups)
|
770
786
|
```
|
771
787
|
|
772
788
|
### vendor/plugins
|
@@ -777,7 +793,7 @@ Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must rep
|
|
777
793
|
|
778
794
|
* Rails 4.0 has removed the identity map from Active Record, due to [some inconsistencies with associations](https://github.com/rails/rails/commit/302c912bf6bcd0fa200d964ec2dc4a44abe328a6). If you have manually enabled it in your application, you will have to remove the following config that has no effect anymore: `config.active_record.identity_map`.
|
779
795
|
|
780
|
-
* The `delete` method in collection associations can now receive `
|
796
|
+
* The `delete` method in collection associations can now receive `Integer` or `String` arguments as record ids, besides records, pretty much like the `destroy` method does. Previously it raised `ActiveRecord::AssociationTypeMismatch` for such arguments. From Rails 4.0 on `delete` automatically tries to find the records matching the given ids before deleting them.
|
781
797
|
|
782
798
|
* In Rails 4.0 when a column or a table is renamed the related indexes are also renamed. If you have migrations which rename the indexes, they are no longer needed.
|
783
799
|
|
@@ -822,6 +838,20 @@ this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
|
|
822
838
|
|
823
839
|
* To re-enable the old finders, you can use the [activerecord-deprecated_finders gem](https://github.com/rails/activerecord-deprecated_finders).
|
824
840
|
|
841
|
+
* Rails 4.0 has changed to default join table for `has_and_belongs_to_many` relations to strip the common prefix off the second table name. Any existing `has_and_belongs_to_many` relationship between models with a common prefix must be specified with the `join_table` option. For example:
|
842
|
+
|
843
|
+
```ruby
|
844
|
+
CatalogCategory < ActiveRecord::Base
|
845
|
+
has_and_belongs_to_many :catalog_products, join_table: 'catalog_categories_catalog_products'
|
846
|
+
end
|
847
|
+
|
848
|
+
CatalogProduct < ActiveRecord::Base
|
849
|
+
has_and_belongs_to_many :catalog_categories, join_table: 'catalog_categories_catalog_products'
|
850
|
+
end
|
851
|
+
```
|
852
|
+
|
853
|
+
* Note that the the prefix takes scopes into account as well, so relations between `Catalog::Category` and `Catalog::Product` or `Catalog::Category` and `CatalogProduct` need to be updated similarly.
|
854
|
+
|
825
855
|
### Active Resource
|
826
856
|
|
827
857
|
Rails 4.0 extracted Active Resource to its own gem. If you still need the feature you can add the [Active Resource gem](https://github.com/rails/activeresource) in your Gemfile.
|
@@ -865,6 +895,8 @@ Please read [Pull Request #9978](https://github.com/rails/rails/pull/9978) for d
|
|
865
895
|
|
866
896
|
* Rails 4.0 has removed the XML parameters parser. You will need to add the `actionpack-xml_parser` gem if you require this feature.
|
867
897
|
|
898
|
+
* Rails 4.0 changes the default `layout` lookup set using symbols or procs that return nil. To get the "no layout" behavior, return false instead of nil.
|
899
|
+
|
868
900
|
* Rails 4.0 changes the default memcached client from `memcache-client` to `dalli`. To upgrade, simply add `gem 'dalli'` to your `Gemfile`.
|
869
901
|
|
870
902
|
* Rails 4.0 deprecates the `dom_id` and `dom_class` methods in controllers (they are fine in views). You will need to include the `ActionView::RecordIdentifier` module in controllers requiring this feature.
|
@@ -1110,7 +1142,7 @@ You can help test performance with these additions to your test environment:
|
|
1110
1142
|
|
1111
1143
|
```ruby
|
1112
1144
|
# Configure static asset server for tests with Cache-Control for performance
|
1113
|
-
config.
|
1145
|
+
config.serve_static_files = true
|
1114
1146
|
config.static_cache_control = 'public, max-age=3600'
|
1115
1147
|
```
|
1116
1148
|
|
@@ -355,7 +355,7 @@ This gem uses Ajax to speed up page rendering in most applications.
|
|
355
355
|
|
356
356
|
Turbolinks attaches a click handler to all `<a>` on the page. If your browser
|
357
357
|
supports
|
358
|
-
[PushState](https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history#The_pushState
|
358
|
+
[PushState](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState%28%29_method),
|
359
359
|
Turbolinks will make an Ajax request for the page, parse the response, and
|
360
360
|
replace the entire `<body>` of the page with the `<body>` of the response. It
|
361
361
|
will then use PushState to change the URL to the correct one, preserving
|
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.
|
4
|
+
version: 4.2.11.3
|
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:
|
11
|
+
date: 2020-05-15 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.
|
19
|
+
version: 4.2.11.3
|
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.
|
26
|
+
version: 4.2.11.3
|
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.
|
33
|
+
version: 4.2.11.3
|
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.
|
40
|
+
version: 4.2.11.3
|
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.
|
47
|
+
version: 4.2.11.3
|
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.
|
54
|
+
version: 4.2.11.3
|
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.
|
61
|
+
version: 4.2.11.3
|
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.
|
68
|
+
version: 4.2.11.3
|
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.
|
75
|
+
version: 4.2.11.3
|
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.
|
82
|
+
version: 4.2.11.3
|
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.
|
89
|
+
version: 4.2.11.3
|
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.
|
96
|
+
version: 4.2.11.3
|
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.
|
103
|
+
version: 4.2.11.3
|
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.
|
110
|
+
version: 4.2.11.3
|
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.
|
117
|
+
version: 4.2.11.3
|
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.
|
124
|
+
version: 4.2.11.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: bundler
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,6 +308,8 @@ files:
|
|
308
308
|
- guides/bug_report_templates/action_controller_master.rb
|
309
309
|
- guides/bug_report_templates/active_record_gem.rb
|
310
310
|
- guides/bug_report_templates/active_record_master.rb
|
311
|
+
- guides/bug_report_templates/generic_gem.rb
|
312
|
+
- guides/bug_report_templates/generic_master.rb
|
311
313
|
- guides/rails_guides.rb
|
312
314
|
- guides/rails_guides/generator.rb
|
313
315
|
- guides/rails_guides/helpers.rb
|
@@ -342,10 +344,10 @@ files:
|
|
342
344
|
- guides/source/api_documentation_guidelines.md
|
343
345
|
- guides/source/asset_pipeline.md
|
344
346
|
- guides/source/association_basics.md
|
347
|
+
- guides/source/autoloading_and_reloading_constants.md
|
345
348
|
- guides/source/caching_with_rails.md
|
346
349
|
- guides/source/command_line.md
|
347
350
|
- guides/source/configuring.md
|
348
|
-
- guides/source/constant_autoloading_and_reloading.md
|
349
351
|
- guides/source/contributing_to_ruby_on_rails.md
|
350
352
|
- guides/source/credits.html.erb
|
351
353
|
- guides/source/debugging_rails_applications.md
|
@@ -397,8 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
397
399
|
- !ruby/object:Gem::Version
|
398
400
|
version: 1.8.11
|
399
401
|
requirements: []
|
400
|
-
|
401
|
-
rubygems_version: 2.2.2
|
402
|
+
rubygems_version: 3.0.3
|
402
403
|
signing_key:
|
403
404
|
specification_version: 4
|
404
405
|
summary: Full-stack web application framework.
|