1.-6ren">
gpt4 book ai didi

mysql - Rails 思维 sphinx 方法

转载 作者:行者123 更新时间:2023-11-29 02:33:57 26 4
gpt4 key购买 nike

我正在尝试在我的 Rails 3 应用程序中设置 Thinking sphinx。我设置了mysql并安装了sphinx没有错误。在我的 gemfile 中有

gem "riddle", "~> 1.5.0"
gem "thinking-sphinx", "~> 2.0.10"

这些安装很好。在我的模型中我有

define_index do
indexes :name
indexes acad_field
indexes expertise
indexes interests
indexes experience
indexes marital_status
indexes email
indexes place_of_birth
indexes birthyear
indexes hometown
indexes current_residence
indexes languages
indexes nationalities
indexes ethnicities_mom_dad
indexes institution
indexes program

end

在我 Controller 的索引中有

def index
#@profiles = Profile.all
@profiles = Profile.search params[:search]
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @profiles }
end
end

在我的 route 有

match "profiles?search=:search", :to => "profiles#index"

当我尝试运行搜索时出现错误

Routing Error

undefined method `define_index' for #<Class:0xb3ada670>

我在这里做错了什么。

最佳答案

我只是想跑

rake thinking_sphinx:rebuild

在终端

关于mysql - Rails 思维 sphinx 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8204425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com