I have a class method like this:
def self.seed
InventoryPeriod.delete_all
(1..8).each do |i|
self.create! name: "name#{i}", start_datetime: DateTime.new(2014,i,1), end_datetime:DateTime.new(2014,i,-1), location_id: 12
end
end
but it seems like it should be writing to the database in UTC (DateTime.new(2014,i,1).utc
doesn't do it) but it doesn't and basically is off by 8 hours.
For example:
| 51 | 2014-08-01 00:00:00 | 2014-08-31 00:00:00
but should be:
| 51 | 2014-07-31 16:00:00 | 2014-08-30 16:00:00
What's the best solution for this? Hopefully, some rails thing that I'm not aware of - would seem like there should be since it must be so common. Or do I manually adjust by the necessary hours?