0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RubyでdummyデータをRandomで値を生成して作成する

Posted at

論文みたく書くのは苦手なので記述だけ。

def self.__create_dummy_tests
    50.times do
      Test.create({
        company_id: rand(Company.count),
        user_id: rand(User.count),
        send_at: Random.rand(Time.zone.now.ago(2.month)..Time.zone.now),
        form_id: SecureRandom.base64(20),
        answered_at: [nil, Random.rand(Time.zone.now.ago(2.month)..Time.zone.now)].sample,
        is_active: [true, false].sample
      })
    end
  end
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?