Skip to content

Commit b61318b

Browse files
authored
Merge pull request rails#54979 from ancao-apvn/fix-words-in-active-record-query-interface-guide
Fix text in the Active Record Query Interface guide [ci skip]
2 parents 99e27fa + 267d39a commit b61318b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

guides/source/active_record_querying.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ SELECT * FROM customers LIMIT 1
244244

245245
The `take` method returns `nil` if no record is found and no exception will be raised.
246246

247-
You can pass in a numerical argument to the `take` method to return up to that number of results. For example
247+
You can pass in a numerical argument to the `take` method to return up to that number of results. For example:
248248

249249
```irb
250250
irb> customers = Customer.take(2)
@@ -283,7 +283,7 @@ The `first` method returns `nil` if no matching record is found and no exception
283283

284284
If your [default scope](active_record_querying.html#applying-a-default-scope) contains an order method, `first` will return the first record according to this ordering.
285285

286-
You can pass in a numerical argument to the `first` method to return up to that number of results. For example
286+
You can pass in a numerical argument to the `first` method to return up to that number of results. For example:
287287

288288
```irb
289289
irb> customers = Customer.first(3)
@@ -361,7 +361,7 @@ SELECT * FROM customers ORDER BY customers.store_id DESC, customers.id DESC LIMI
361361

362362
If your [default scope](active_record_querying.html#applying-a-default-scope) contains an order method, `last` will return the last record according to this ordering.
363363

364-
You can pass in a numerical argument to the `last` method to return up to that number of results. For example
364+
You can pass in a numerical argument to the `last` method to return up to that number of results. For example:
365365

366366
```irb
367367
irb> customers = Customer.last(3)
@@ -978,7 +978,7 @@ Limit and Offset
978978

979979
To apply `LIMIT` to the SQL fired by the `Model.find`, you can specify the `LIMIT` using [`limit`][] and [`offset`][] methods on the relation.
980980

981-
You can use `limit` to specify the number of records to be retrieved, and use `offset` to specify the number of records to skip before starting to return the records. For example
981+
You can use `limit` to specify the number of records to be retrieved, and use `offset` to specify the number of records to skip before starting to return the records. For example:
982982

983983
```ruby
984984
Customer.limit(5)
@@ -1150,15 +1150,15 @@ Compare this to the case where the `reselect` clause is not used:
11501150
Book.select(:title, :isbn).select(:created_at)
11511151
```
11521152

1153-
the SQL executed would be:
1153+
The SQL executed would be:
11541154

11551155
```sql
11561156
SELECT books.title, books.isbn, books.created_at FROM books
11571157
```
11581158

11591159
### `reorder`
11601160

1161-
The [`reorder`][] method overrides the default scope order. For example if the class definition includes this:
1161+
The [`reorder`][] method overrides the default scope order. For example, if the class definition includes this:
11621162

11631163
```ruby
11641164
class Author < ApplicationRecord
@@ -1240,7 +1240,7 @@ If the `rewhere` clause is not used, the where clauses are ANDed together:
12401240
Book.where(out_of_print: true).where(out_of_print: false)
12411241
```
12421242

1243-
the SQL executed would be:
1243+
The SQL executed would be:
12441244

12451245
```sql
12461246
SELECT * FROM books WHERE out_of_print = 1 AND out_of_print = 0
@@ -1269,7 +1269,7 @@ If the `regroup` clause is not used, the group clauses are combined together:
12691269
Book.group(:author).group(:id)
12701270
```
12711271

1272-
the SQL executed would be:
1272+
The SQL executed would be:
12731273

12741274
```sql
12751275
SELECT * FROM books GROUP BY author, id
@@ -1734,7 +1734,7 @@ NOTE: The `preload` method uses an array, hash, or a nested hash of array/hash i
17341734

17351735
With `eager_load`, Active Record loads all specified associations using a `LEFT OUTER JOIN`.
17361736

1737-
Revisiting the case where N + 1 was occurred using the `eager_load` method, we could rewrite `Book.limit(10)` to authors:
1737+
Revisiting the case where N + 1 was occurred using the `eager_load` method, we could rewrite `Book.limit(10)` to eager load authors:
17381738

17391739
```ruby
17401740
books = Book.eager_load(:author).limit(10)
@@ -2133,7 +2133,7 @@ Understanding Method Chaining
21332133
-----------------------------
21342134

21352135
The Active Record pattern implements [Method Chaining](https://en.wikipedia.org/wiki/Method_chaining),
2136-
which allow us to use multiple Active Record methods together in a simple and straightforward way.
2136+
which allows us to use multiple Active Record methods together in a simple and straightforward way.
21372137

21382138
You can chain methods in a statement when the previous method called returns an
21392139
[`ActiveRecord::Relation`][], like `all`, `where`, and `joins`. Methods that return
@@ -2294,7 +2294,7 @@ irb> nina.save
22942294
Finding by SQL
22952295
--------------
22962296

2297-
If you'd like to use your own SQL to find records in a table you can use [`find_by_sql`][]. The `find_by_sql` method will return an array of objects even if the underlying query returns just a single record. For example you could run this query:
2297+
If you'd like to use your own SQL to find records in a table you can use [`find_by_sql`][]. The `find_by_sql` method will return an array of objects even if the underlying query returns just a single record. For example, you could run this query:
22982298

22992299
```irb
23002300
irb> Customer.find_by_sql("SELECT * FROM customers INNER JOIN orders ON customers.id = orders.customer_id ORDER BY customers.created_at desc")

0 commit comments

Comments
 (0)