Reputation: 14818
I have a DATETIME column called last_profile_update. I need to update it with a current time. I have the following code:
user = User.new
user.last_profile_update = Date.today
user.save
but it does not work.
Upvotes: 17
Views: 28318
Reputation: 1492
It could be done with:
user.last_profile_update = Date.today.to_datetime
Upvotes: 1
Reputation: 10856
Perhaps a way to simplify that code:
user = User.create(:last_profile_update => Time.now)
Upvotes: 29
Reputation: 14818
Figured it was Time.now
user = User.new
user.last_profile_update = Time.now
user.save
Upvotes: 1