Skip to content

create fake comments

Dave Kaplan edited this page May 18, 2018 · 2 revisions
cids = [1413, 1415, 1410, 1305, 1290]
uids = [1,2,3,5,6,8,9]
cids.each do |cid|
  c = Collection.find cid
  u = User.find(uids.sample)
  ct = CommentThread.find_or_create_by(record: c)
  ct.save
  rand(1..4).times do
    time = rand(100...25000).minutes.ago
    if rand < 0.5
      m = Faker::BackToTheFuture.quote
    else
      m = Faker::Simpsons.quote
    end
    FactoryBot.create(:comment, comment_thread: ct, author: u, created_at: time, message: m)
  end
end
Clone this wiki locally