按ID搜索,没有关键字。尝试使用:条件但没有结果输出

时间:2011-01-15 07:39:49

标签: ruby-on-rails thinking-sphinx

使用Thinking Sphinx,Rails 2.3.8。

我没有要搜索的关键字,但我想搜索被编入索引的shop_id。这是我的代码:

  @country = Country.search '', {
    :with           => {:shop_id => params[:shop_id]},
    :group_by       => 'state_id',
    :group_function => :attr,
    :page           => params[:page]
  }

以上一项有效。但我认为''相当多余。所以我将其替换为:conditions,结果为:

  @country = Country.search :conditions => {
    :with           => {:shop_id => params[:shop_id]},
    :group_by       => 'state_id',
    :group_function => :attr,
    :page           => params[:page]
  }

然后它给出0结果。什么是正确的代码?

感谢。

1 个答案:

答案 0 :(得分:0)

进入控制台,看看你是否无法改变:条件。看起来通过删除空白字符串,您只需为gem设置默认参数。在您的供应商处获取Gem并查看Country Class以查看接受的内容。

相关问题