Keenanp Keenanp - 5 months ago 9x
Ruby Question

Seeding objects with datetime Rails

I'm trying to seed multiple files to my rails app to test the page structure, and one of the attributes is a datetime stamp. However, I can't figure out how to seed this field. I've tried created_at, but it's not recognized. I couldn't find an example in the ruby docs or railscast, unfortunately.

Any idea how to go about doing this? Thanks

12.times { Post.create(title: 'pellentesque', body: 'Lorem ut vehicula', postnumber: '1', date: created_at, image_url: '') }


The variable passed to date: needs to be a date or time object:

some_date = 4.days.ago

12.times do 
    title: 'pellentesque', 
    body: 'Lorem ut vehicula', 
    postnumber: '1', 
    date: some_date, # some_date passed to date attribute
    image_url: ''