Skip to content
This repository
Browse code

Re: #431 -- Added a note about `strategy: :build`

  • Loading branch information...
commit fd56f884e4093339c6ef81a70746ea9672c2802e 1 parent 71c1336
Hosam Aly authored September 07, 2012 joshuaclayton committed November 02, 2012

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  GETTING_STARTED.md
9  GETTING_STARTED.md
Source Rendered
@@ -336,6 +336,15 @@ post.new_record?        # => true
336 336
 post.author.new_record? # => true
337 337
 ```
338 338
 
  339
+Please note that the `strategy: :build` option must be passed to an explicit call to `association`,
  340
+and cannot be used with implicit associations:
  341
+
  342
+```ruby
  343
+factory :post do
  344
+  # ...
  345
+  author strategy: :build    # <<< this does *not* work; causes author_id to be nil
  346
+```
  347
+
339 348
 Generating data for a `has_many` relationship is a bit more involved,
340 349
 depending on the amount of flexibility desired, but here's a surefire example
341 350
 of generating associated data.

0 notes on commit fd56f88

Please sign in to comment.
Something went wrong with that request. Please try again.