mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
[ci skip] Remove duplicated last! section.
Reference: d4fd0bd177
cc @schneems
This commit is contained in:
parent
758ae37305
commit
59b93dfda7
1 changed files with 0 additions and 17 deletions
|
@ -267,23 +267,6 @@ This is equivalent to writing:
|
|||
Client.where(first_name: 'does not exist').take!
|
||||
```
|
||||
|
||||
#### `last!`
|
||||
|
||||
`Model.last!` finds the last record ordered by the primary key. For example:
|
||||
|
||||
```ruby
|
||||
client = Client.last!
|
||||
# => #<Client id: 221, first_name: "Russel">
|
||||
```
|
||||
|
||||
The SQL equivalent of the above is:
|
||||
|
||||
```sql
|
||||
SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1
|
||||
```
|
||||
|
||||
`Model.last!` raises `ActiveRecord::RecordNotFound` if no matching record is found.
|
||||
|
||||
### Retrieving Multiple Objects in Batches
|
||||
|
||||
We often need to iterate over a large set of records, as when we send a newsletter to a large set of users, or when we export data.
|
||||
|
|
Loading…
Reference in a new issue