Rails思维狮身人面像方法
我正在尝试在我的 Rails 3 应用程序中设置 Think 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
,我在控制器的索引中,
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
在我的路线中,
match "profiles?search=:search", :to => "profiles#index"
当我尝试运行搜索时,我收到错误“
Routing Error
undefined method `define_index' for #<Class:0xb3ada670>
我在这里做错了什么”。
Im trying to set up thinking sphinx in my rails 3 app. I set up mysql and installed sphinx without error. In my gemfile i have
gem "riddle", "~> 1.5.0"
gem "thinking-sphinx", "~> 2.0.10"
These install fine. In my model i have
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
and in my index in my controller i have
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
in my routes i have
match "profiles?search=:search", :to => "profiles#index"
when i try running a search i get the error
Routing Error
undefined method `define_index' for #<Class:0xb3ada670>
What i am doing wrong here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只需要
在终端中运行
I just needed to run
in terminal
根据 @fuzzyalej 评论,所需的步骤是:
gem "thinking-sphinx", "~> 2.0.10", :require => 'thinking_sphinx'
Based on @fuzzyalej comment, the needed steps are:
gem "thinking-sphinx", "~> 2.0.10", :require => 'thinking_sphinx'
在 gemfile 中添加 gem 规范后,您可能没有运行“bundle install”,我不认为 rake ts:rebuild 实际上解决了这个问题:)
you probably didn't run 'bundle install' after adding the gem specification in your gemfile, I don't think rake ts:rebuild actually solved this issue :)