If you have created_at and updated_at columns in the DB table. Rails will automatically set these values when you create and update a model object. There are chances that we have to update the columns without touching these columns.
You can do this anywhere like in migration or in a rake task:
ActiveRecord::Base.record_timestamps = false
begin
importing_data_code
ensure
ActiveRecord::Base.record_timestamps = true # don't forget to enable it again!
end
You can safely set created_at and updated_at manually, Rails won't complain.
Note: This can also work on the individual models, e.g.
Person.record_timestamps = false
0 Comment(s)