1
0
Fork 0
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:
Richard Gould 2022-01-14 21:10:54 +01:00 committed by GitHub
parent b7eb4db87c
commit fc098ffbc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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