LoginSignup
0
0

More than 1 year has passed since last update.

Railsでupdated_atがばらばらなテストデータを作りたい

Last updated at Posted at 2023-02-02

備忘録

結論

gem fakerを利用するぅ

group :development, :test do
   gem 'faker'
end

今回は既存データをアップデートしてます。

models.each do |hoge|
    fake_date = Faker::Date.between(from: 100.days.ago, to: Date.today)
    hoge.update(Model.touch_attributes_with_time(*[], time: fake_date))
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