2012-03-19 22 views
11

我有Rails 3.1.3應用程序,並試圖插入寶石「redis」。找不到緩存存儲適配器redis_store

我添加以下寶石的Gemfile:

寶石 「的Redis店」

這篇文章之後,我已經添加以下代碼,以環境/ development.rb:

config.gem "redis-store", :lib => "redis-store" 
require "redis-store" # HACK 
config.cache_store = :redis_store 

該應用無法啓動,抱怨cache_store:

/gems/activesupport-3.1.3/lib/active_support/cache.rb:65:in`lookup_store':找不到緩存存儲適配器對於redis_store(無需加載此文件 - active_support/cache/redis_store)(RuntimeError)。

我已經想通了,包括寶石「redis的護欄」,而不是「redis的店」,但我發現了另一個錯誤:

/Users/AntonAL/.rvm/gems/[email protected]/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `gem': redis-store is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

保持他們兩個......

gem 'redis-store' 
gem 'redis-rails' 

...給出了另一個錯誤

…gems/redis-rails-0.0.0/lib/redis-rails/version.rb:1: Redis is not a module (TypeError) 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require' 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require' 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency' 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in' 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency' 
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require' 
    from …/gems/redis-rails-0.0.0/lib/redis-rails.rb:1 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require' 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' 
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require' 
    from …/gems/bundler-1.0.21/lib/bundler.rb:122:in `require' 
    from …/config/application.rb:11 
    from …/gems/railties-3.1.3/lib/rails/commands.rb:52:in `require' 
    from …/gems/railties-3.1.3/lib/rails/commands.rb:52 
    from …/gems/railties-3.1.3/lib/rails/commands.rb:49:in `tap' 
    from …/gems/railties-3.1.3/lib/rails/commands.rb:49 
    from script/rails:6:in `require' 
    from script/rails:6 

幫助,請!

回答

9

嘗試

gem 'redis-store', '~> 1.0.0' 
+1

謝謝,最近我還找到了解決方案。我可以指定與我的rails環境版本相匹配的「redis-store」版本。 – AntonAL 2012-03-26 12:01:15

+0

Blam!感謝噸million.rand – Trip 2012-05-01 19:20:46

9

僅供參考......我有類似的問題,直到我說以下所有對我的Gemfile的。我正在運行Rails 3.2.3。

gem 'redis' 
    gem 'redis-store' 
    gem 'redis-rails' 
+8

我有一個類似的問題與Rails 3.2.3。我用'gem'redis-rails''取代了'gem'redis-store'',一切正常。 – Ross 2012-07-17 01:26:37

+1

這是多餘的 - ''redis-rails'包含另外兩個寶石作爲依賴關係 – Yarin 2014-02-15 16:20:09

0

我想這是你在你的評論,AntonAL的意思 - 這是爲我工作:

gem 'redis-rails', RAILS_VERSION # Where RAILS_VERSION matches the version of your rails gem 

無法獲得比:)

+1

這些版本碰巧同步是巧合。絕對不是使用Gemfile的可取方法。 – jordanpg 2013-05-30 01:48:59