These columns created_at, updated_at, created_on, updated_on are automatically processed by you using rails.
However, there are a few notes:
- Do not change the attr value (i.e.,
created_at must be nil before creation and must not be changed before the update ). Otherwise, ActiveRecord will not update the attr value with the current time. - Verify that
<ClassName>.record_timestamps set to true.
In addition, I suggest that you add a non-zero constraint to these columns:
change_column :<table_name>, :created_at, :datetime, :null => false
This way you will be sure that this column always has a value other than zero.
melekes
source share