Ruby 在 Rails - 计数器缓存在生产环境中不起作用

Ruby on Rails - Counter cache doesn't work on production

我已将 counter_cache 添加到 punching_bag gem。在 Development ENV 中一切正常,但在 Production ENV 中它没有按照预期的方式运行。

我可以看到 punches_count 列已添加到我的 posts table 中,但 increment 列中没有。

为什么会发生这种情况,我该如何解决?

Post 模型中添加以下内容:

attr_accessor :punches_count

has_many :punches