rails 4.2.1 → 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 +76 -1
- data/guides/Rakefile +16 -3
- 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/4_2_release_notes.md +24 -0
- data/guides/source/_welcome.html.erb +5 -1
- data/guides/source/action_mailer_basics.md +4 -1
- 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 +5 -40
- data/guides/source/association_basics.md +14 -4
- data/guides/source/autoloading_and_reloading_constants.md +2 -1
- data/guides/source/configuring.md +29 -4
- data/guides/source/contributing_to_ruby_on_rails.md +3 -3
- data/guides/source/engines.md +10 -10
- data/guides/source/getting_started.md +19 -24
- data/guides/source/i18n.md +1 -1
- 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 +1 -1
- data/guides/source/upgrading_ruby_on_rails.md +17 -1
- data/guides/source/working_with_javascript_in_rails.md +1 -1
- metadata +21 -20
data/guides/source/i18n.md
CHANGED
@@ -685,7 +685,7 @@ you can safely pass the username as set by the user:
|
|
685
685
|
|
686
686
|
```erb
|
687
687
|
<%# This is safe, it is going to be escaped if needed. %>
|
688
|
-
<%= t('welcome_html', username: @current_user.username %>
|
688
|
+
<%= t('welcome_html', username: @current_user.username) %>
|
689
689
|
```
|
690
690
|
|
691
691
|
Safe strings on the other hand are interpolated verbatim.
|
@@ -161,7 +161,7 @@ throwing an error message. If the command is valid, a method of the same name
|
|
161
161
|
is called.
|
162
162
|
|
163
163
|
```ruby
|
164
|
-
COMMAND_WHITELIST = %(plugin generate destroy console server dbconsole application runner new version help)
|
164
|
+
COMMAND_WHITELIST = %w(plugin generate destroy console server dbconsole application runner new version help)
|
165
165
|
|
166
166
|
def run_command!(command)
|
167
167
|
command = parse_command(command)
|
@@ -29,14 +29,11 @@
|
|
29
29
|
More Ruby on Rails
|
30
30
|
</span>
|
31
31
|
<ul class="more-info-links s-hidden">
|
32
|
-
<li class="more-info"><a href="http://rubyonrails.org/">Overview</a></li>
|
33
|
-
<li class="more-info"><a href="http://rubyonrails.org/download">Download</a></li>
|
34
|
-
<li class="more-info"><a href="http://rubyonrails.org/deploy">Deploy</a></li>
|
35
|
-
<li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
|
36
|
-
<li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
|
37
|
-
<li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
|
38
|
-
<li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
|
39
32
|
<li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
|
33
|
+
<li class="more-info"><a href="http://guides.rubyonrails.org/">Guides</a></li>
|
34
|
+
<li class="more-info"><a href="http://api.rubyonrails.org/">API</a></li>
|
35
|
+
<li class="more-info"><a href="http://stackoverflow.com/questions/tagged/ruby-on-rails">Ask for help</a></li>
|
36
|
+
<li class="more-info"><a href="https://github.com/rails/rails">Contribute on GitHub</a></li>
|
40
37
|
</ul>
|
41
38
|
</div>
|
42
39
|
</div>
|
@@ -175,23 +175,22 @@ render template: "products/show"
|
|
175
175
|
|
176
176
|
#### Rendering an Arbitrary File
|
177
177
|
|
178
|
-
The `render` method can also use a view that's entirely outside of your application
|
179
|
-
|
180
|
-
```ruby
|
181
|
-
render "/u/apps/warehouse_app/current/app/views/products/show"
|
182
|
-
```
|
183
|
-
|
184
|
-
Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the `:file` option (which was required on Rails 2.2 and earlier):
|
178
|
+
The `render` method can also use a view that's entirely outside of your application:
|
185
179
|
|
186
180
|
```ruby
|
187
181
|
render file: "/u/apps/warehouse_app/current/app/views/products/show"
|
188
182
|
```
|
189
183
|
|
190
|
-
The `:file` option takes an absolute file-system path. Of course, you need to have rights
|
184
|
+
The `:file` option takes an absolute file-system path. Of course, you need to have rights
|
185
|
+
to the view that you're using to render the content.
|
186
|
+
|
187
|
+
NOTE: Using the `:file` option in combination with users input can lead to security problems
|
188
|
+
since an attacker could use this action to access security sensitive files in your file system.
|
191
189
|
|
192
190
|
NOTE: By default, the file is rendered using the current layout.
|
193
191
|
|
194
|
-
TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to
|
192
|
+
TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to
|
193
|
+
render a file, because Windows filenames do not have the same format as Unix filenames.
|
195
194
|
|
196
195
|
#### Wrapping it up
|
197
196
|
|
@@ -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
@@ -950,7 +950,7 @@ In order to test that your mailer is working as expected, you can use unit tests
|
|
950
950
|
|
951
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.
|
952
952
|
|
953
|
-
|
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.
|
954
954
|
|
955
955
|
#### The Basic Test Case
|
956
956
|
|
@@ -793,7 +793,7 @@ Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must rep
|
|
793
793
|
|
794
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`.
|
795
795
|
|
796
|
-
* 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.
|
797
797
|
|
798
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.
|
799
799
|
|
@@ -838,6 +838,20 @@ this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
|
|
838
838
|
|
839
839
|
* To re-enable the old finders, you can use the [activerecord-deprecated_finders gem](https://github.com/rails/activerecord-deprecated_finders).
|
840
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
|
+
|
841
855
|
### Active Resource
|
842
856
|
|
843
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.
|
@@ -881,6 +895,8 @@ Please read [Pull Request #9978](https://github.com/rails/rails/pull/9978) for d
|
|
881
895
|
|
882
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.
|
883
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
|
+
|
884
900
|
* Rails 4.0 changes the default memcached client from `memcache-client` to `dalli`. To upgrade, simply add `gem 'dalli'` to your `Gemfile`.
|
885
901
|
|
886
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.
|
@@ -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
|
@@ -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.4.5
|
402
|
+
rubygems_version: 3.0.3
|
402
403
|
signing_key:
|
403
404
|
specification_version: 4
|
404
405
|
summary: Full-stack web application framework.
|