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
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,8 +1,83 @@
|
|
1
|
-
## Rails 4.2.
|
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) ##
|
2
62
|
|
3
63
|
* No Changes *
|
4
64
|
|
5
65
|
|
66
|
+
## Rails 4.2.3 (June 25, 2015) ##
|
67
|
+
|
68
|
+
* No Changes *
|
69
|
+
|
70
|
+
|
71
|
+
## Rails 4.2.2 (June 16, 2015) ##
|
72
|
+
|
73
|
+
* No Changes *
|
74
|
+
|
75
|
+
|
76
|
+
## Rails 4.2.1 (March 19, 2015) ##
|
77
|
+
|
78
|
+
* No changes.
|
79
|
+
|
80
|
+
|
6
81
|
## Rails 4.2.0 (December 20, 2014) ##
|
7
82
|
|
8
83
|
* New guide about constant autoloading and reloading.
|
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
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Activate the gems you are reporting the issue against.
|
2
|
+
gem 'activesupport', '4.2.0'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
# Ensure backward compatibility with Minitest 4
|
8
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
9
|
+
|
10
|
+
class BugTest < Minitest::Test
|
11
|
+
def test_stuff
|
12
|
+
assert "zomg".present?
|
13
|
+
refute "".present?
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
unless File.exist?('Gemfile')
|
2
|
+
File.write('Gemfile', <<-GEMFILE)
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'arel', github: 'rails/arel'
|
6
|
+
GEMFILE
|
7
|
+
|
8
|
+
system 'bundle'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'bundler'
|
12
|
+
Bundler.setup(:default)
|
13
|
+
|
14
|
+
require 'active_support'
|
15
|
+
require 'active_support/core_ext/object/blank'
|
16
|
+
require 'minitest/autorun'
|
17
|
+
|
18
|
+
# Ensure backward compatibility with Minitest 4
|
19
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
20
|
+
|
21
|
+
class BugTest < Minitest::Test
|
22
|
+
def test_stuff
|
23
|
+
assert "zomg".present?
|
24
|
+
refute "".present?
|
25
|
+
end
|
26
|
+
end
|
@@ -300,6 +300,30 @@ application is using any of these spellings, you will need to update them:
|
|
300
300
|
assert_select('p', 'AT&T') # => false
|
301
301
|
```
|
302
302
|
|
303
|
+
Furthermore substitutions have changed syntax.
|
304
|
+
|
305
|
+
Now you have to use a `:match` CSS-like selector:
|
306
|
+
|
307
|
+
```ruby
|
308
|
+
assert_select ":match('id', ?)", 'comment_1'
|
309
|
+
```
|
310
|
+
|
311
|
+
Additionally Regexp substitutions look different when the assertion fails.
|
312
|
+
Notice how `/hello/` here:
|
313
|
+
|
314
|
+
```ruby
|
315
|
+
assert_select(":match('id', ?)", /hello/)
|
316
|
+
```
|
317
|
+
|
318
|
+
becomes `"(?-mix:hello)"`:
|
319
|
+
|
320
|
+
```
|
321
|
+
Expected at least 1 element matching "div:match('id', "(?-mix:hello)")", found 0..
|
322
|
+
Expected 0 to be >= 1.
|
323
|
+
```
|
324
|
+
|
325
|
+
See the [Rails Dom Testing](https://github.com/rails/rails-dom-testing/tree/8798b9349fb9540ad8cb9a0ce6cb88d1384a210b) documentation for more on `assert_select`.
|
326
|
+
|
303
327
|
|
304
328
|
Railties
|
305
329
|
--------
|
@@ -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>
|
@@ -507,6 +507,9 @@ url helper.
|
|
507
507
|
<%= user_url(@user, host: 'example.com') %>
|
508
508
|
```
|
509
509
|
|
510
|
+
NOTE: non-`GET` links require [jQuery UJS](https://github.com/rails/jquery-ujs)
|
511
|
+
and won't work in mailer templates. They will result in normal `GET` requests.
|
512
|
+
|
510
513
|
### Sending Multipart Emails
|
511
514
|
|
512
515
|
Action Mailer will automatically send multipart emails if you have different
|
@@ -670,7 +673,7 @@ files (environment.rb, production.rb, etc...)
|
|
670
673
|
| Configuration | Description |
|
671
674
|
|---------------|-------------|
|
672
675
|
|`logger`|Generates information on the mailing run if available. Can be set to `nil` for no logging. Compatible with both Ruby's own `Logger` and `Log4r` loggers.|
|
673
|
-
|`smtp_settings`|Allows detailed configuration for `:smtp` delivery method:<ul><li>`:address` - Allows you to use a remote mail server. Just change it from its default `"localhost"` setting.</li><li>`:port` - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li>`:domain` - If you need to specify a HELO domain, you can do it here.</li><li>`:user_name` - If your mail server requires authentication, set the username in this setting.</li><li>`:password` - If your mail server requires authentication, set the password in this setting.</li><li>`:authentication` - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of `:plain
|
676
|
+
|`smtp_settings`|Allows detailed configuration for `:smtp` delivery method:<ul><li>`:address` - Allows you to use a remote mail server. Just change it from its default `"localhost"` setting.</li><li>`:port` - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li>`:domain` - If you need to specify a HELO domain, you can do it here.</li><li>`:user_name` - If your mail server requires authentication, set the username in this setting.</li><li>`:password` - If your mail server requires authentication, set the password in this setting.</li><li>`:authentication` - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of `:plain` (will send the password in the clear), `:login` (will send password Base64 encoded) or `:cram_md5` (combines a Challenge/Response mechanism to exchange information and a cryptographic Message Digest 5 algorithm to hash important information)</li><li>`:enable_starttls_auto` - Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to `true`.</li><li>`:openssl_verify_mode` - When using TLS, you can set how OpenSSL checks the certificate. This is really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name of an OpenSSL verify constant ('none', 'peer', 'client_once', 'fail_if_no_peer_cert') or directly the constant (`OpenSSL::SSL::VERIFY_NONE`, `OpenSSL::SSL::VERIFY_PEER`, ...).</li></ul>|
|
674
677
|
|`sendmail_settings`|Allows you to override options for the `:sendmail` delivery method.<ul><li>`:location` - The location of the sendmail executable. Defaults to `/usr/sbin/sendmail`.</li><li>`:arguments` - The command line arguments to be passed to sendmail. Defaults to `-i -t`.</li></ul>|
|
675
678
|
|`raise_delivery_errors`|Whether or not errors should be raised if the email fails to be delivered. This only works if the external email server is configured for immediate delivery.|
|
676
679
|
|`delivery_method`|Defines a delivery method. Possible values are:<ul><li>`:smtp` (default), can be configured by using `config.action_mailer.smtp_settings`.</li><li>`:sendmail`, can be configured by using `config.action_mailer.sendmail_settings`.</li><li>`:file`: save emails to files; can be configured by using `config.action_mailer.file_settings`.</li><li>`:test`: save emails to `ActionMailer::Base.deliveries` array.</li></ul>See [API docs](http://api.rubyonrails.org/classes/ActionMailer/Base.html) for more info.|
|
@@ -435,39 +435,13 @@ config.action_controller.asset_host = "assets.example.com"
|
|
435
435
|
image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
|
436
436
|
```
|
437
437
|
|
438
|
-
#### register_javascript_expansion
|
439
|
-
|
440
|
-
Register one or more JavaScript files to be included when symbol is passed to javascript_include_tag. This method is typically intended to be called from plugin initialization to register JavaScript files that the plugin installed in `vendor/assets/javascripts`.
|
441
|
-
|
442
|
-
```ruby
|
443
|
-
ActionView::Helpers::AssetTagHelper.register_javascript_expansion monkey: ["head", "body", "tail"]
|
444
|
-
|
445
|
-
javascript_include_tag :monkey # =>
|
446
|
-
<script src="/assets/head.js"></script>
|
447
|
-
<script src="/assets/body.js"></script>
|
448
|
-
<script src="/assets/tail.js"></script>
|
449
|
-
```
|
450
|
-
|
451
|
-
#### register_stylesheet_expansion
|
452
|
-
|
453
|
-
Register one or more stylesheet files to be included when symbol is passed to `stylesheet_link_tag`. This method is typically intended to be called from plugin initialization to register stylesheet files that the plugin installed in `vendor/assets/stylesheets`.
|
454
|
-
|
455
|
-
```ruby
|
456
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion monkey: ["head", "body", "tail"]
|
457
|
-
|
458
|
-
stylesheet_link_tag :monkey # =>
|
459
|
-
<link href="/assets/head.css" media="screen" rel="stylesheet" />
|
460
|
-
<link href="/assets/body.css" media="screen" rel="stylesheet" />
|
461
|
-
<link href="/assets/tail.css" media="screen" rel="stylesheet" />
|
462
|
-
```
|
463
|
-
|
464
438
|
#### auto_discovery_link_tag
|
465
439
|
|
466
440
|
Returns a link tag that browsers and feed readers can use to auto-detect an RSS or Atom feed.
|
467
441
|
|
468
442
|
```ruby
|
469
|
-
auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {title: "RSS Feed"}) # =>
|
470
|
-
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed" />
|
443
|
+
auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", { title: "RSS Feed" }) # =>
|
444
|
+
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed.rss" />
|
471
445
|
```
|
472
446
|
|
473
447
|
#### image_path
|
@@ -1136,14 +1110,6 @@ If `@article.author_ids` is [1], this would return:
|
|
1136
1110
|
<input name="article[author_ids][]" type="hidden" value="" />
|
1137
1111
|
```
|
1138
1112
|
|
1139
|
-
#### country_options_for_select
|
1140
|
-
|
1141
|
-
Returns a string of option tags for pretty much any country in the world.
|
1142
|
-
|
1143
|
-
#### country_select
|
1144
|
-
|
1145
|
-
Returns select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
1146
|
-
|
1147
1113
|
#### option_groups_from_collection_for_select
|
1148
1114
|
|
1149
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.
|
@@ -1420,22 +1386,6 @@ date_field_tag "dob"
|
|
1420
1386
|
|
1421
1387
|
Provides functionality for working with JavaScript in your views.
|
1422
1388
|
|
1423
|
-
#### button_to_function
|
1424
|
-
|
1425
|
-
Returns a button that'll trigger a JavaScript function using the onclick handler. Examples:
|
1426
|
-
|
1427
|
-
```ruby
|
1428
|
-
button_to_function "Greeting", "alert('Hello world!')"
|
1429
|
-
button_to_function "Delete", "if (confirm('Really?')) do_delete()"
|
1430
|
-
button_to_function "Details" do |page|
|
1431
|
-
page[:details].visual_effect :toggle_slide
|
1432
|
-
end
|
1433
|
-
```
|
1434
|
-
|
1435
|
-
#### define_javascript_functions
|
1436
|
-
|
1437
|
-
Includes the Action Pack JavaScript libraries inside a single `script` tag.
|
1438
|
-
|
1439
1389
|
#### escape_javascript
|
1440
1390
|
|
1441
1391
|
Escape carrier returns and single and double quotes for JavaScript segments.
|
@@ -1456,15 +1406,6 @@ alert('All is good')
|
|
1456
1406
|
</script>
|
1457
1407
|
```
|
1458
1408
|
|
1459
|
-
#### link_to_function
|
1460
|
-
|
1461
|
-
Returns a link that will trigger a JavaScript function using the onclick handler and return false after the fact.
|
1462
|
-
|
1463
|
-
```ruby
|
1464
|
-
link_to_function "Greeting", "alert('Hello world!')"
|
1465
|
-
# => <a onclick="alert('Hello world!'); return false;" href="#">Greeting</a>
|
1466
|
-
```
|
1467
|
-
|
1468
1409
|
### NumberHelper
|
1469
1410
|
|
1470
1411
|
Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
|
@@ -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
|
|
@@ -171,18 +171,18 @@ name that should be used:
|
|
171
171
|
|
172
172
|
```ruby
|
173
173
|
class Product < ActiveRecord::Base
|
174
|
-
self.table_name = "
|
174
|
+
self.table_name = "my_products"
|
175
175
|
end
|
176
176
|
```
|
177
177
|
|
178
178
|
If you do so, you will have to define manually the class name that is hosting
|
179
|
-
the fixtures (
|
179
|
+
the fixtures (my_products.yml) using the `set_fixture_class` method in your test
|
180
180
|
definition:
|
181
181
|
|
182
182
|
```ruby
|
183
|
-
class
|
184
|
-
set_fixture_class
|
185
|
-
fixtures :
|
183
|
+
class ProductTest < ActiveSupport::TestCase
|
184
|
+
set_fixture_class my_products: Product
|
185
|
+
fixtures :my_products
|
186
186
|
...
|
187
187
|
end
|
188
188
|
```
|
@@ -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
|