Ruby Forum Ruby on Rails > memcache-client config problem

Posted by Krates Ng (krates)
on 13.07.2007 23:17
I am trying to use memcache-client to store session.  I have found great
instructions online.  However, I keep getting error and fail to start
rails on radrails.

I have "gem install memcache-client":

============ gem list ===============
memcache-client (1.3.0)
    A Ruby memcached client
=====================================

I've configured with the following:

=========== environment.rb  ===============
require_gem 'memcache-client'
Rails::Initializer.run do |config|
   config.action_controller.session_store =:mem_cache_store
end
memcache_options = {
   :compression => true,
   :debug => false,
   :namespace => "pr-#{RAILS_ENV}",
   :readonly => false,
   :urlencode => false
}
memcache_servers = [ '127.0.0.1:11211' ]
CACHE = MemCache.new(memcache_options)
CACHE.servers = memcache_servers
ActionController::Base.session_options[:cache] = CACHE
============================================

I keep getting either of these errors (depending on whichever one comes
first in environment.rb:


=========== errors  ===============
uninitialized constant CGI::Session::MemCacheStore (NameError)

<or>

uninitialized constant MemCache (NameError)
===================================


memcache-client appears to have loaded properly with require_gem. I
tried changing the config many times, but keep getting these errors.
Any help would be greatly appreciated.

thanks a lot!
-Krates
Posted by Nathaniel Brown (nshb)
on 26.03.2008 01:03
This is due to not having at least "hoe" and maybe "rubyforge" gems not 
also updated.

Just do a global update if you don't have any others, but otherwise just 
try going into irb and directly including the memcache-client lib.

# irb
> require 'rubygems'
> gem 'memcache-client'

You should get an error here about what's missing.

Nathaniel.

Krates Ng wrote:
> I am trying to use memcache-client to store session.  I have found great
> instructions online.  However, I keep getting error and fail to start
> rails on radrails.
> 
> I have "gem install memcache-client":
> 
> ============ gem list ===============
> memcache-client (1.3.0)
>     A Ruby memcached client
> =====================================
> 
> I've configured with the following:
> 
> =========== environment.rb  ===============
> require_gem 'memcache-client'
> Rails::Initializer.run do |config|
>    config.action_controller.session_store =:mem_cache_store
> end
> memcache_options = {
>    :compression => true,
>    :debug => false,
>    :namespace => "pr-#{RAILS_ENV}",
>    :readonly => false,
>    :urlencode => false
> }
> memcache_servers = [ '127.0.0.1:11211' ]
> CACHE = MemCache.new(memcache_options)
> CACHE.servers = memcache_servers
> ActionController::Base.session_options[:cache] = CACHE
> ============================================
> 
> I keep getting either of these errors (depending on whichever one comes
> first in environment.rb:
> 
> 
> =========== errors  ===============
> uninitialized constant CGI::Session::MemCacheStore (NameError)
> 
> <or>
> 
> uninitialized constant MemCache (NameError)
> ===================================
> 
> 
> memcache-client appears to have loaded properly with require_gem. I
> tried changing the config many times, but keep getting these errors.
> Any help would be greatly appreciated.
> 
> thanks a lot!
> -Krates