Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写我的第一个 Ruby on Rails 应用程序,我注意到生成迁移会将时间戳列添加到表中。我以前使用过时间戳(例如,在订购以查找最新记录时)。如果您不打算使用这些时间戳列,是否有任何理由保留它们?
如果您不打算使用它们,则没有任何好处。Rails 添加这些是为了您自己的理智和实用性,以便能够查看记录的创建和/或更新时间。
如果您想关闭它,您可能需要添加以下内容:
config.active_record.record_timestamps = false
不,那里没有。但是您严重限制了您订购和审核数据的能力。