Time not renewed in heroics

I am seriously confused about what could go wrong.

I logged in heroku run consoleand tried to update the timestamp in my database.

I started User.find(6)to see what the user has :next_click = 2000-01-01..., I don’t know why this value is, but in any case I do User.update 6, {:next_click => Time.utc(2015)}and it seems to update correctly 2015-01-01 00:00:00, however when I do another User.find(6), it seems that the time has switched back because it is not 2015-01-01 00:00:00.

I am really confused why this is not so. Any insight?

SEE ADJUSTED SCREENSHOT enter image description here

irb(main):033:0> User.update 6, {:next_click => Time.utc(2015) }
  User Load (34.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 6]]
   (1.8ms)  BEGIN
   (2.2ms)  UPDATE "users" SET "next_click" = '2015-01-01 00:00:00.000000', "updated_at" = '2012-05-24 00:13:26.197358' WHERE "users"."id" = 6
   (2.2ms)  COMMIT
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2015-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 00:13:26">
irb(main):034:0> User.find(6)
  User Load (2.4ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 6]]
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2000-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 00:13:26">

The same thing happens with u = User.find(6) u.next_click = Time.utc(2013), thenu.save

irb(main):001:0> u = User.find(6)
  User Load (38.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 6]]
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2000-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 00:57:28">
irb(main):002:0> u.next_click = Time.utc(2013)
=> 2013-01-01 00:00:00 UTC
irb(main):003:0> u
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2013-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 00:57:28">
irb(main):004:0> u.save
   (10.9ms)  BEGIN
   (3.7ms)  UPDATE "users" SET "next_click" = '2013-01-01 00:00:00.000000', "updated_at" = '2012-05-24 03:05:46.059530' WHERE "users"."id" = 6
   (2.2ms)  COMMIT
=> true
irb(main):005:0> u
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2013-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 03:05:46">
irb(main):006:0> User.find(6)
  User Load (33.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 6]]
=> #<User id: 6, name: "mazlix", gold: 10, points: 10, next_click: "2000-01-01 00:00:00", created_at: "2012-05-23 23:40:39", updated_at: "2012-05-24 03:05:46">

app/models/user.rb:

class User < ActiveRecord::Base
  attr_accessible :gold, :name, :next_click, :points
end
+5
source share
2 answers

. , ruby ​​ Time + , ( //) , : .

Ruby , , rails Time, .

, , a: datetime ( Time .

+6

ActiveRecord :timestamp :datetime .

+1

All Articles