rails 4.2.3 → 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 +65 -0
- data/guides/Rakefile +16 -3
- data/guides/source/_welcome.html.erb +5 -1
- data/guides/source/action_view_overview.md +0 -8
- data/guides/source/active_job_basics.md +27 -6
- data/guides/source/active_record_basics.md +1 -1
- data/guides/source/active_record_querying.md +0 -2
- data/guides/source/active_record_validations.md +3 -2
- data/guides/source/active_support_core_extensions.md +2 -3
- 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 -5
- data/guides/source/association_basics.md +1 -1
- data/guides/source/configuring.md +29 -4
- data/guides/source/contributing_to_ruby_on_rails.md +3 -3
- data/guides/source/getting_started.md +4 -9
- 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 +3 -1
- data/guides/source/security.md +1 -1
- data/guides/source/testing.md +1 -1
- data/guides/source/upgrading_ruby_on_rails.md +1 -1
- data/guides/source/working_with_javascript_in_rails.md +1 -1
- metadata +19 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d4073c294efe444213b93605bd058bdfcfe7fd21df0673d411aaacb8444d6311
|
4
|
+
data.tar.gz: 6ced0776f690d103fd1ae235809fe9244f59538b6153c5f75247e76a35c9f600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e399f8b1df884ceb451de70d9e0a821f1a0c4621eb7ee8af0e9fdc1a955661aab731e6b9a7b3928f09d2a86d492ec737f5c488709d2ba734cbb9a42a1ef5e829
|
7
|
+
data.tar.gz: d302ab1709953482477f8ca896e45e54d69c8dcc16edf1f49e09ce1c8b451d0a1725baf3d3c7a2b138b97ca0018813e2cf907db01768188a8a025e68c4679b16
|
data/guides/CHANGELOG.md
CHANGED
@@ -1,3 +1,68 @@
|
|
1
|
+
## Rails 4.2.11.3 (May 15, 2020) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 4.2.11.2 (May 15, 2020) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
|
+
|
10
|
+
|
11
|
+
## Rails 4.2.11.1 (March 11, 2019) ##
|
12
|
+
|
13
|
+
* No changes.
|
14
|
+
|
15
|
+
|
16
|
+
## Rails 4.2.11 (November 27, 2018) ##
|
17
|
+
|
18
|
+
* No changes.
|
19
|
+
|
20
|
+
|
21
|
+
## Rails 4.2.10 (September 27, 2017) ##
|
22
|
+
|
23
|
+
* No changes.
|
24
|
+
|
25
|
+
|
26
|
+
## Rails 4.2.9 (June 26, 2017) ##
|
27
|
+
|
28
|
+
* No changes.
|
29
|
+
|
30
|
+
|
31
|
+
## Rails 4.2.8 (February 21, 2017) ##
|
32
|
+
|
33
|
+
* No changes.
|
34
|
+
|
35
|
+
|
36
|
+
## Rails 4.2.7 (July 12, 2016) ##
|
37
|
+
|
38
|
+
* No changes.
|
39
|
+
|
40
|
+
|
41
|
+
## Rails 4.2.6 (March 07, 2016) ##
|
42
|
+
|
43
|
+
* No changes.
|
44
|
+
|
45
|
+
|
46
|
+
## Rails 4.2.5.2 (February 26, 2016) ##
|
47
|
+
|
48
|
+
* No changes.
|
49
|
+
|
50
|
+
|
51
|
+
## Rails 4.2.5.1 (January 25, 2016) ##
|
52
|
+
|
53
|
+
* No changes.
|
54
|
+
|
55
|
+
|
56
|
+
## Rails 4.2.5 (November 12, 2015) ##
|
57
|
+
|
58
|
+
* No changes.
|
59
|
+
|
60
|
+
|
61
|
+
## Rails 4.2.4 (August 24, 2015) ##
|
62
|
+
|
63
|
+
* No Changes *
|
64
|
+
|
65
|
+
|
1
66
|
## Rails 4.2.3 (June 25, 2015) ##
|
2
67
|
|
3
68
|
* No Changes *
|
data/guides/Rakefile
CHANGED
@@ -3,16 +3,29 @@ namespace :guides do
|
|
3
3
|
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"'
|
4
4
|
task :generate => 'generate:html'
|
5
5
|
|
6
|
+
# Guides are written in UTF-8, but the environment may be configured for some
|
7
|
+
# other locale, these tasks are responsible for ensuring the default external
|
8
|
+
# encoding is UTF-8.
|
9
|
+
#
|
10
|
+
# Real use cases: Generation was reported to fail on a machine configured with
|
11
|
+
# GBK (Chinese). The docs server once got misconfigured somehow and had "C",
|
12
|
+
# which broke generation too.
|
13
|
+
task :encoding do
|
14
|
+
%w(LANG LANGUAGE LC_ALL).each do |env_var|
|
15
|
+
ENV[env_var] = "en_US.UTF-8"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
namespace :generate do
|
7
20
|
|
8
21
|
desc "Generate HTML guides"
|
9
|
-
task :html do
|
22
|
+
task :html => :encoding do
|
10
23
|
ENV["WARN_BROKEN_LINKS"] = "1" # authors can't disable this
|
11
24
|
ruby "rails_guides.rb"
|
12
25
|
end
|
13
26
|
|
14
27
|
desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/kindlepublishing"
|
15
|
-
task :kindle do
|
28
|
+
task :kindle => :encoding do
|
16
29
|
unless `kindlerb -v 2> /dev/null` =~ /kindlerb 0.1.1/
|
17
30
|
abort "Please `gem install kindlerb` and make sure you have `kindlegen` in your PATH"
|
18
31
|
end
|
@@ -26,7 +39,7 @@ namespace :guides do
|
|
26
39
|
|
27
40
|
# Validate guides -------------------------------------------------------------------------
|
28
41
|
desc 'Validate guides, use ONLY=foo to process just "foo.html"'
|
29
|
-
task :validate do
|
42
|
+
task :validate => :encoding do
|
30
43
|
ruby "w3c_validator.rb"
|
31
44
|
end
|
32
45
|
|
@@ -15,5 +15,9 @@
|
|
15
15
|
</p>
|
16
16
|
<% end %>
|
17
17
|
<p>
|
18
|
-
The guides for earlier releases:
|
18
|
+
The guides for earlier releases:
|
19
|
+
<a href="http://guides.rubyonrails.org/v4.1/">Rails 4.1</a>,
|
20
|
+
<a href="http://guides.rubyonrails.org/v4.0/">Rails 4.0</a>,
|
21
|
+
<a href="http://guides.rubyonrails.org/v3.2/">Rails 3.2</a>, and
|
22
|
+
<a href="http://guides.rubyonrails.org/v2.3/">Rails 2.3</a>.
|
19
23
|
</p>
|
@@ -1110,14 +1110,6 @@ If `@article.author_ids` is [1], this would return:
|
|
1110
1110
|
<input name="article[author_ids][]" type="hidden" value="" />
|
1111
1111
|
```
|
1112
1112
|
|
1113
|
-
#### country_options_for_select
|
1114
|
-
|
1115
|
-
Returns a string of option tags for pretty much any country in the world.
|
1116
|
-
|
1117
|
-
#### country_select
|
1118
|
-
|
1119
|
-
Returns select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
1120
|
-
|
1121
1113
|
#### option_groups_from_collection_for_select
|
1122
1114
|
|
1123
1115
|
Returns a string of `option` tags, like `options_from_collection_for_select`, but groups them by `optgroup` tags based on the object relationships of the arguments.
|
@@ -65,33 +65,41 @@ Here's what a job looks like:
|
|
65
65
|
class GuestsCleanupJob < ActiveJob::Base
|
66
66
|
queue_as :default
|
67
67
|
|
68
|
-
def perform(*
|
68
|
+
def perform(*guests)
|
69
69
|
# Do something later
|
70
70
|
end
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
Note that you can define `perform` with as many arguments as you want.
|
75
|
+
|
74
76
|
### Enqueue the Job
|
75
77
|
|
76
78
|
Enqueue a job like so:
|
77
79
|
|
78
80
|
```ruby
|
79
|
-
# Enqueue a job to be performed as soon the
|
80
|
-
|
81
|
+
# Enqueue a job to be performed as soon the queuing system is
|
82
|
+
# free.
|
83
|
+
GuestsCleanupJob.perform_later guest
|
81
84
|
```
|
82
85
|
|
83
86
|
```ruby
|
84
87
|
# Enqueue a job to be performed tomorrow at noon.
|
85
|
-
|
88
|
+
GuestsCleanupJob.set(wait_until: Date.tomorrow.noon).perform_later(guest)
|
86
89
|
```
|
87
90
|
|
88
91
|
```ruby
|
89
92
|
# Enqueue a job to be performed 1 week from now.
|
90
|
-
|
93
|
+
GuestsCleanupJob.set(wait: 1.week).perform_later(guest)
|
91
94
|
```
|
92
95
|
|
93
|
-
|
96
|
+
```ruby
|
97
|
+
# `perform_now` and `perform_later` will call `perform` under the hood so
|
98
|
+
# you can pass as many arguments as defined in the latter.
|
99
|
+
GuestsCleanupJob.perform_later(guest1, guest2, filter: 'some_filter')
|
100
|
+
```
|
94
101
|
|
102
|
+
That's it!
|
95
103
|
|
96
104
|
Job Execution
|
97
105
|
-------------
|
@@ -266,6 +274,19 @@ UserMailer.welcome(@user).deliver_later
|
|
266
274
|
```
|
267
275
|
|
268
276
|
|
277
|
+
Internationalization
|
278
|
+
--------------------
|
279
|
+
|
280
|
+
Each job uses the `I18n.locale` set when the job was created. Useful if you send
|
281
|
+
emails asynchronously:
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
I18n.locale = :eo
|
285
|
+
|
286
|
+
UserMailer.welcome(@user).deliver_later # Email will be localized to Esparanto.
|
287
|
+
```
|
288
|
+
|
289
|
+
|
269
290
|
GlobalID
|
270
291
|
--------
|
271
292
|
|
@@ -258,7 +258,7 @@ david = User.find_by(name: 'David')
|
|
258
258
|
|
259
259
|
```ruby
|
260
260
|
# find all users named David who are Code Artists and sort by created_at in reverse chronological order
|
261
|
-
users = User.where(name: 'David', occupation: 'Code Artist').order(
|
261
|
+
users = User.where(name: 'David', occupation: 'Code Artist').order(created_at: :desc)
|
262
262
|
```
|
263
263
|
|
264
264
|
You can learn more about querying an Active Record model in the [Active Record
|
@@ -332,8 +332,6 @@ User.find_each(start: 2000, batch_size: 5000) do |user|
|
|
332
332
|
end
|
333
333
|
```
|
334
334
|
|
335
|
-
Another example would be if you wanted multiple workers handling the same processing queue. You could have each worker handle 10000 records by setting the appropriate `:start` option on each worker.
|
336
|
-
|
337
335
|
#### `find_in_batches`
|
338
336
|
|
339
337
|
The `find_in_batches` method is similar to `find_each`, since both retrieve batches of records. The difference is that `find_in_batches` yields _batches_ to the block as an array of models, instead of individually. The following example will yield to the supplied block an array of up to 1000 invoices at a time, with the final block containing any remaining invoices:
|
@@ -944,8 +944,9 @@ own custom validators.
|
|
944
944
|
|
945
945
|
You can also create methods that verify the state of your models and add
|
946
946
|
messages to the `errors` collection when they are invalid. You must then
|
947
|
-
register these methods by using the `validate`
|
948
|
-
|
947
|
+
register these methods by using the `validate`
|
948
|
+
([API](http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate))
|
949
|
+
class method, passing in the symbols for the validation methods' names.
|
949
950
|
|
950
951
|
You can pass more than one symbol for each class method and the respective
|
951
952
|
validations will be run in the same order as they were registered.
|
@@ -1760,7 +1760,7 @@ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
|
|
1760
1760
|
The method `constantize` resolves the constant reference expression in its receiver:
|
1761
1761
|
|
1762
1762
|
```ruby
|
1763
|
-
"
|
1763
|
+
"Integer".constantize # => Integer
|
1764
1764
|
|
1765
1765
|
module M
|
1766
1766
|
X = 1
|
@@ -2612,8 +2612,7 @@ To do so, the method loops over the pairs and builds nodes that depend on the _v
|
|
2612
2612
|
```ruby
|
2613
2613
|
XML_TYPE_NAMES = {
|
2614
2614
|
"Symbol" => "symbol",
|
2615
|
-
"
|
2616
|
-
"Bignum" => "integer",
|
2615
|
+
"Integer" => "integer",
|
2617
2616
|
"BigDecimal" => "decimal",
|
2618
2617
|
"Float" => "float",
|
2619
2618
|
"TrueClass" => "boolean",
|
@@ -305,17 +305,6 @@ Action Mailer
|
|
305
305
|
}
|
306
306
|
```
|
307
307
|
|
308
|
-
ActiveResource
|
309
|
-
--------------
|
310
|
-
|
311
|
-
### request.active_resource
|
312
|
-
|
313
|
-
| Key | Value |
|
314
|
-
| -------------- | -------------------- |
|
315
|
-
| `:method` | HTTP method |
|
316
|
-
| `:request_uri` | Complete URI |
|
317
|
-
| `:result` | HTTP response object |
|
318
|
-
|
319
308
|
Active Support
|
320
309
|
--------------
|
321
310
|
|
@@ -111,7 +111,7 @@ On the other hand, big chunks of structured documentation may have a separate "E
|
|
111
111
|
The results of expressions follow them and are introduced by "# => ", vertically aligned:
|
112
112
|
|
113
113
|
```ruby
|
114
|
-
# For checking if
|
114
|
+
# For checking if an integer is even or odd.
|
115
115
|
#
|
116
116
|
# 1.even? # => false
|
117
117
|
# 1.odd? # => true
|
@@ -434,11 +434,11 @@ Sprockets uses manifest files to determine which assets to include and serve.
|
|
434
434
|
These manifest files contain _directives_ - instructions that tell Sprockets
|
435
435
|
which files to require in order to build a single CSS or JavaScript file. With
|
436
436
|
these directives, Sprockets loads the files specified, processes them if
|
437
|
-
necessary, concatenates them into one single file and then compresses them
|
438
|
-
`Rails.application.config.assets.
|
439
|
-
than many, the load time of pages can be greatly reduced because
|
440
|
-
makes fewer requests. Compression also reduces file size, enabling
|
441
|
-
browser to download them faster.
|
437
|
+
necessary, concatenates them into one single file and then compresses them
|
438
|
+
(based on value of `Rails.application.config.assets.js_compressor`). By serving
|
439
|
+
one file rather than many, the load time of pages can be greatly reduced because
|
440
|
+
the browser makes fewer requests. Compression also reduces file size, enabling
|
441
|
+
the browser to download them faster.
|
442
442
|
|
443
443
|
|
444
444
|
For example, a new Rails 4 application includes a default
|
@@ -33,7 +33,7 @@ In general, the work of configuring Rails means configuring the components of Ra
|
|
33
33
|
For example, the `config/application.rb` file includes this setting:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
config.
|
36
|
+
config.time_zone = 'Central Time (US & Canada)'
|
37
37
|
```
|
38
38
|
|
39
39
|
This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same `config` object in `config/application.rb`:
|
@@ -139,8 +139,6 @@ pipeline is enabled. It is set to true by default.
|
|
139
139
|
|
140
140
|
* `config.assets.raise_runtime_errors` Set this flag to `true` to enable additional runtime error checking. Recommended in `config/environments/development.rb` to minimize unexpected behavior when deploying to `production`.
|
141
141
|
|
142
|
-
* `config.assets.compress` a flag that enables the compression of compiled assets. It is explicitly set to true in `config/environments/production.rb`.
|
143
|
-
|
144
142
|
* `config.assets.css_compressor` defines the CSS compressor to use. It is set by default by `sass-rails`. The unique alternative value at the moment is `:yui`, which uses the `yui-compressor` gem.
|
145
143
|
|
146
144
|
* `config.assets.js_compressor` defines the JavaScript compressor to use. Possible values are `:closure`, `:uglifier` and `:yui` which require the use of the `closure-compiler`, `uglifier` or `yui-compressor` gems respectively.
|
@@ -1027,7 +1025,7 @@ NOTE. If you are running in a multi-threaded environment, there could be a chanc
|
|
1027
1025
|
Custom configuration
|
1028
1026
|
--------------------
|
1029
1027
|
|
1030
|
-
You can configure your own code through the Rails configuration object with custom configuration. It works like this:
|
1028
|
+
You can configure your own code through the Rails configuration object with custom configuration under the `config.x` property. It works like this:
|
1031
1029
|
|
1032
1030
|
```ruby
|
1033
1031
|
config.x.payment_processing.schedule = :daily
|
@@ -1043,3 +1041,30 @@ These configuration points are then available through the configuration object:
|
|
1043
1041
|
Rails.configuration.x.super_debugger # => true
|
1044
1042
|
Rails.configuration.x.super_debugger.not_set # => nil
|
1045
1043
|
```
|
1044
|
+
|
1045
|
+
You can also use Rails::Application.config_for to load whole configuration files:
|
1046
|
+
|
1047
|
+
```ruby
|
1048
|
+
# config/payment.yml:
|
1049
|
+
production:
|
1050
|
+
environment: production
|
1051
|
+
merchant_id: production_merchant_id
|
1052
|
+
public_key: production_public_key
|
1053
|
+
private_key: production_private_key
|
1054
|
+
development:
|
1055
|
+
environment: sandbox
|
1056
|
+
merchant_id: development_merchant_id
|
1057
|
+
public_key: development_public_key
|
1058
|
+
private_key: development_private_key
|
1059
|
+
|
1060
|
+
# config/application.rb
|
1061
|
+
module MyApp
|
1062
|
+
class Application < Rails::Application
|
1063
|
+
config.x.payment = config_for(:payment)
|
1064
|
+
end
|
1065
|
+
end
|
1066
|
+
```
|
1067
|
+
|
1068
|
+
```ruby
|
1069
|
+
Rails.configuration.x.payment['merchant_id'] # => production_merchant_id or development_merchant_id
|
1070
|
+
```
|
@@ -119,11 +119,11 @@ Contributing to the Rails Documentation
|
|
119
119
|
Ruby on Rails has two main sets of documentation: the guides, which help you
|
120
120
|
learn about Ruby on Rails, and the API, which serves as a reference.
|
121
121
|
|
122
|
-
You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails.
|
122
|
+
You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails.
|
123
123
|
|
124
124
|
You can either open a pull request to [Rails](http://github.com/rails/rails) or
|
125
125
|
ask the [Rails core team](http://rubyonrails.org/core) for commit access on
|
126
|
-
|
126
|
+
docrails if you contribute regularly.
|
127
127
|
Please do not open pull requests in docrails, if you'd like to get feedback on your
|
128
128
|
change, ask for it in [Rails](http://github.com/rails/rails) instead.
|
129
129
|
|
@@ -281,7 +281,7 @@ You can run a single test through ruby. For instance:
|
|
281
281
|
|
282
282
|
```bash
|
283
283
|
$ cd actionmailer
|
284
|
-
$ ruby -w -Itest test/mail_layout_test.rb -n test_explicit_class_layout
|
284
|
+
$ bundle exec ruby -w -Itest test/mail_layout_test.rb -n test_explicit_class_layout
|
285
285
|
```
|
286
286
|
|
287
287
|
The `-n` option allows you to run a single method instead of the whole
|
@@ -1536,20 +1536,17 @@ class CreateComments < ActiveRecord::Migration
|
|
1536
1536
|
create_table :comments do |t|
|
1537
1537
|
t.string :commenter
|
1538
1538
|
t.text :body
|
1539
|
-
|
1540
|
-
# this line adds an integer column called `article_id`.
|
1541
|
-
t.references :article, index: true
|
1539
|
+
t.references :article, index: true, foreign_key: true
|
1542
1540
|
|
1543
1541
|
t.timestamps null: false
|
1544
1542
|
end
|
1545
|
-
add_foreign_key :comments, :articles
|
1546
1543
|
end
|
1547
1544
|
end
|
1548
1545
|
```
|
1549
1546
|
|
1550
|
-
The `t.references` line
|
1551
|
-
|
1552
|
-
|
1547
|
+
The `t.references` line creates an integer column called `article_id`, an index
|
1548
|
+
for it, and a foreign key constraint that points to the `articles` table. Go
|
1549
|
+
ahead and run the migration:
|
1553
1550
|
|
1554
1551
|
```bash
|
1555
1552
|
$ bin/rake db:migrate
|
@@ -1562,8 +1559,6 @@ run against the current database, so in this case you will just see:
|
|
1562
1559
|
== CreateComments: migrating =================================================
|
1563
1560
|
-- create_table(:comments)
|
1564
1561
|
-> 0.0115s
|
1565
|
-
-- add_foreign_key(:comments, :articles)
|
1566
|
-
-> 0.0000s
|
1567
1562
|
== CreateComments: migrated (0.0119s) ========================================
|
1568
1563
|
```
|
1569
1564
|
|
@@ -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:
|
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
|
|
@@ -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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
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.3
|
124
|
+
version: 4.2.11.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: bundler
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -399,8 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
399
|
- !ruby/object:Gem::Version
|
400
400
|
version: 1.8.11
|
401
401
|
requirements: []
|
402
|
-
|
403
|
-
rubygems_version: 2.4.5
|
402
|
+
rubygems_version: 3.0.3
|
404
403
|
signing_key:
|
405
404
|
specification_version: 4
|
406
405
|
summary: Full-stack web application framework.
|