I have Rails 3.1.3 app and trying to plug gem "redis" to it.
I've added following gem to Gemfile:
gem "redis-store"
Following this article, i've added following code to environments/development.rb:
config.gem "redis-store", :lib => "redis-store"
require "redis-store" # HACK
config.cache_store = :redis_store
The app won't start, complaining to cache_store:
/gems/activesupport-3.1.3/lib/active_support/cache.rb:65:in `lookup_store': Could not find cache store adapter for redis_store (no such file to load -- active_support/cache/redis_store) (RuntimeError).
I've figured it out, including gem "redis-rails" instead of "redis-store", but i'm getting another error:
/Users/AntonAL/.rvm/gems/ree-1.8.7-2011.03@global/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)
Keeping them both…
gem 'redis-store'
gem 'redis-rails'
…gives another error
…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
Help, please!
try
gem 'redis-store', '~> 1.0.0'
FYI... I had similar problems until I added all of the following to my Gemfile. I am running Rails 3.2.3.
gem 'redis'
gem 'redis-store'
gem 'redis-rails'
This is all you need:
gem 'redis-rails' # Will install several other redis-* gems
(See: https://github.com/redis-store/redis-rails)
I faced a similar problem with a Rails 5.2 app.
Turns out the problem was with the configuration of the cache store in production.rb
. Rails guides indicates using config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'] }
, but this is not correct.
What worked for me:
In Gemfile
gem 'redis-rails', '~> 5'
In config/environments/production.rb
config.cache_store = :redis_store, ENV['REDIS_URL']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With