【问题标题】:upgrading Thinking Sphinx - deep association升级 Thinking Sphinx - 深度联想
【发布时间】:2016-01-26 19:30:55
【问题描述】:

在从 TS 2.x 升级到 TS 3.1.1 时遇到问题

我有一个直通关联: bar has_many category_groups 到 bar_category_groups

在我的 bar 索引中,我有这个,它工作正常:

有 bar_category_groups(:category_group_id), :as => :cat_groups

我也有模型“foo”,它属于酒吧。 在我的 foo 索引中,我之前有过这个,它在 TS 2.x 中运行良好

有 bar.bar_category_groups(:category_group_id), :as => :cat_groups

在 TS 3 中,我收到“ThinkingSphinx::MissingColumnError: column bar_category_groups 不存在”

我的索引顶部也有 bar 和 bar.bar_category_groups 的连接。

似乎我们失去了将直通关联挂在属于关联(如果您愿意的话,是“深度”关联)的能力。

【问题讨论】:

    标签: ruby-on-rails thinking-sphinx


    【解决方案1】:

    您不需要将列作为方法参数 - 相反,只需将其作为方法链接即可:

    has bar.bar_category_groups.category_group_id, :as => :cat_groups
    

    参数语法是添加到旧版本 TS 以解决 Ruby 1.8 中的保留方法的东西 - 但现在 BasicObject 是一个东西,它不再需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多