【问题标题】:Is there any way to do a counter_cache with an HABTM?有没有办法用 HABTM 做一个 counter_cache ?
【发布时间】:2013-03-27 13:11:53
【问题描述】:

我在 Google 中看到的所有结果似乎都来自 Rails 2.x 和 3.0。

鉴于 Rails 4 指日可待,是否有任何更改允许我们在 HABTM 关联中使用 counter_cache?

【问题讨论】:

    标签: ruby-on-rails has-and-belongs-to-many ruby-on-rails-4


    【解决方案1】:

    据我所知,我也没有在 Rails 4 里程碑中看到任何似乎暗示其他问题的问题。我一直在密切关注事态发展,但并不虔诚。您可以随时查看 Rails 4 里程碑并仔细查看 https://github.com/rails/rails/issues?milestone=9,但在 Rails 4 博客文章中,http://weblog.rubyonrails.org/2013/2/25/Rails-4-0-beta1/ 没有提到第一个测试版。

    【讨论】:

      【解决方案2】:

      我为 HABTM association here 创建了 counter_cache 功能。

      如果您有任何建议,请随时告诉我。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-05-09
        • 2021-07-09
        • 1970-01-01
        • 2012-01-10
        • 2012-04-18
        • 2021-10-17
        • 2020-05-17
        • 2011-03-12
        相关资源
        最近更新 更多