1
0

More than 1 year has passed since last update.

#Rails の FactoryBot + create_list で毎回ランダムに異なる値を 引数に与える方法は?

Last updated at Posted at 2019-12-07

ないっぽいよ! 愚直にeach / map しよう。

%w(NYC Boston SF Austin).map do |tb_location|
  FactoryBot.create(:location, city: tb_location)
end

create_list with different values for the same attribute · Issue #787 · thoughtbot/factory_bot

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