通过覆盖下面两个方法可以实现,虽然使用场景不多,但也是个 Feature
class User < ActiveRecord::Base
# 非必需,但是 Rails 源码是 Private 的,尽量保持一致
private
def timestamp_attributes_for_create
["created_at", "created_on"]
end
def timestamp_attributes_for_update
["updated_at", "updated_on"]
end
end
Rails 源码在这 https://github.com/rails/rails/blob/master/activerecord/lib/active_record/timestamp.rb#L69-L75
希望我不是最后一个知道的。