You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, giving a block to author means it will be recognized as a dynamic attribute, not an association (internally therefore there will be no distinction between body and author, they are simply fields FactoryBot populates by running a block).
In addition, there is a deep rooted assumption in the code base that an association cannot be passed a block, it can only have traits and attribute overrides.
Maybe this post factory could work for you?
factory:postdobody{"the post body"}authorblog{association:blog,authors: [author]}end
Description
Hi team!
I noticed that FactoryBot is executing the associations block even when I'm using
attributes_for
.When I have one block which depends on another association, ruby is going to generate an
undefined method "the-association-name" for nil:NilClass
.I expected that the associations blocks weren't executed.
Thanks. You're great 💜!
Reproduction Steps
Expected behavior
I expected that the associations blocks weren't executed or the associations data were valids.
Actual behavior
The associations blocks are being executed with invalid data.
The text was updated successfully, but these errors were encountered: