mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Update GETTING_STARTED: include note about saving in create_list
(#1522)
Fixes #1444 and #1479 Add a short note in GETTING_STARTED.md about the need to save the record after it has been modified
This commit is contained in:
parent
b7eb4db87c
commit
fc098ffbc3
1 changed files with 9 additions and 0 deletions
|
@ -1583,6 +1583,15 @@ twenty_somethings = build_list(:user, 10) do |user, i|
|
|||
end
|
||||
```
|
||||
|
||||
`create_list` passes saved instances into the block. If you modify the instance, you must save it again:
|
||||
|
||||
```ruby
|
||||
twenty_somethings = create_list(:user, 10) do |user, i|
|
||||
user.date_of_birth = (20 + i).years.ago
|
||||
user.save!
|
||||
end
|
||||
```
|
||||
|
||||
`build_stubbed_list` will give you fully stubbed out instances:
|
||||
|
||||
```ruby
|
||||
|
|
Loading…
Reference in a new issue