LoginSignup
1
0

More than 1 year has passed since last update.

#Ruby / #Rails の #FactoryBot で association 記法を使わずに create と attributes_for の挙動を使い分ける例

Last updated at Posted at 2019-07-28

#Ruby / # Rails #FactoryBot example of using create and attributes_for behavior without using association notation

FactoryBot.define do
  factory :user do
    book do |factory_bot|
      if factory_bot.attribute_lists?
        nil
      else
        create :book
      end
    end
  end
end

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0