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.
我有一个具有以下字段的模型
更新模型时,我想将published_at设置为Time.now,当published设置为true时!
有什么建议我怎么能做到这一点?谢谢!
在你的模型中,你需要把这个
before_save :set_published_at def set_published_at @published_at = Time.now if @published == true end