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.
也许是一种简化该代码的方法:
user = User.create(:last_profile_update => Time.now)
可以用
user.touch(:last_profile_update)
Figured it was Time.now
user = User.new
user.last_profile_update = Time.now
user.save
可以通过以下方式完成:
user.last_profile_update = Date.today.to_datetime
User.create({:last_profile_update=>Time.now})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.