Rails sets updated_at
to the current time because, well, thats when the record was most recently updated. It sees an update as a creation. If you want to check if something has ever been updated, check to see if its updated_at
and created_at
are the same.
Otherwise, you should be able to change the value inserted by forcing the attribute upon insertion.
Post.new(@params.merge({:updated_at => DateTime::new})
or, in a before_create
method on your model, set self.updated_at = DateTime::new
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…