How do i save a current date/time for a DATETIME column in rails 3

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.

Answers


Perhaps a way to simplify that code:

user = User.create(:last_profile_update => Time.now)

It could be done with

user.touch(:last_profile_update)

User.create({:last_profile_update=>Time.now})

Figured it was Time.now

user = User.new
user.last_profile_update = Time.now
user.save

It could be done with:

user.last_profile_update = Date.today.to_datetime

Need Your Help

Corner case in using lambdas expression in base constructor

c# linq c#-3.0 lambda

In the Framework we are building we need the following pattern: