我使用IndexTank和Tanker gem在我的Rails应用程序上实现全文搜索,但出现错误(URI :: InvalidURIError bad URI(is不是URI?))当试图在我的索引上使用search_tank方法时。URI :: InvalidURIError坏URI(不是URI?):使用Tanker
这是控制器的方法,我得到的错误
def search
if params[:query]
@posts = Post.search_tank(params[:query], :page => 1, :per_page => 10)
else
@posts = []
end
end
这是我的Post模型,我定义索引的部分
if ENV['RAILS_ENV'] === "production"
index = 'idx'
else
index = 'test'
end
tankit index do
indexes :title
indexes :description
end
# define the callbacks to update or delete the index
after_save :update_tank_indexes
after_destroy :delete_tank_indexes
的search_tank方法的工作,当我测试它在轨道控制台。其他帖子似乎表明,这可能与在config/routes.rb中设置的路由有关。我所设定的就是这个。
root :to => 'public#index'
match ':controller(/:action(/:id))(.:format)'
我已经搜索了周围的答案,但我有点难住。任何帮助将不胜感激。
感谢您的回应。我遵循了事先提到的指南,无法实现。在重新启动我的Web服务器(我可能应该尝试之前)之后,我设法让它工作。我想如果它在rails控制台中工作,它应该可以在我的应用程序中工作。 – sjbamber 2012-03-26 00:16:34