heroku上的sunspot_solr错误?

时间:2012-12-19 12:07:11

标签: ruby-on-rails ruby solr sunspot-rails sunspot-solr

我在我的rails应用程序中使用'sunspot_rails', '~> 2.0.0.pre.120415'进行Solr搜索并将其部署在heroku上(两个单独的应用程序)。 它在一个应用程序上工作正常但在其他应用程序上抛出错误。

我检查了heroku环境并发现 - 一个应用程序在雪松堆栈上,ruby版本是1.9.2p290。 (工作正常) 另一个在竹堆上,红宝石版是1.9.2p180(抛出错误)

那么,这是ruby版本问题还是heroku堆栈问题? 开发环境中的Ruby版本是1.9.2p290。

错误

$ heroku run rake sunspot:reindex
Running rake sunspot:reindex attached to terminal... up, run.8567
rake aborted!
uninitialized constant Sunspot::Adapters::Registry::Forwardable
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:310:in `<class:Registry>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:309:in `<module:Adapters>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:34:in `<module:Sunspot>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:18:in `block in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot/rails.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot_rails.rb:6:in `<top (required)>'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

2 个答案:

答案 0 :(得分:0)

我找到了解决方案。

实际上它是heroku上的环境问题。在本地系统上,ruby版本是ruby 1.9.2p290,而heroku是ruby 1.9.2p180。 Ruby 1.9.2p180不包括“可转发”#39;模块。所以我只需要包含&#39; Forwardable&#39;我的申请中的模块。

答案 1 :(得分:0)

更清楚的是,在adapters.rb(sunspot / lib / sunspot / adapters.rb)的顶部,添加以下行:

 require 'forwardable'


 module Sunspot
   #
   # Sunspot works by saving references to the primary key (or natural ID) of