0

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

我检查了 heroku 环境,发现 - 一个应用程序在 cedar 堆栈上,而 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)
4

2 回答 2

0

我找到了解决方案。

实际上这是heroku的环境问题。在本地系统上,ruby版本是ruby 1.9.2p290,在heroku上是ruby 1.9.2p180。Ruby 1.9.2p180 不包含“可转发”模块。所以我只需要在我的应用程序中包含“Forwardable”模块。

于 2013-01-14T10:55:08.987 回答
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
于 2013-03-23T23:23:31.237 回答