Using memcached in Rails app with Single Table Inheritance?

Using memcached in Rails app with Single Table Inheritance?

I have a Rails app that uses STI to handle different types of Users, such as:

class Admin < User   ... end 

I want to use memcached, but I keep getting the dreaded "unknown class/module" error. I've tried pre-loading all of my ActiveRecord models to no avail. The first request works as normal, but the first pull from memcached errors out. I've followed these instructions to no avail either.

Is using memcached possible with single table inheritance?

Route chaining in Rails?


Deploy from Git using Capistrano without a hard reset?
I think this is due to lazy loading of the classes.

Rails routing for namespaced resource deletion
When you call it from memcached the class definition isn't loaded, and then you get the error..
Order of scopes in ActiveRecord/Rails queries
The workaround I use is:.
Retrieving and Ordering Multiple Arrays From ActiveRecord Join table - Ruby on Rails
Admin #lazily load the class definition  # do whatever that has cached Admins 

Rails: Authorization with Authlogic

Rails Nested Route For Singular Resource


Can't get value params[:user] first request using mongrel_rails start?
The problem was that restful_authentication's login_from_session method was being loaded before the aforementioned before_filter was run.

Pre-loading the STI user classes at the top of this method worked..


just a quick comment, i've read that using require_dependency 'admin' is preferred now, not sure why.
require_dependency 'region' 
Also, I've found that this is unnecessary if you add.
config.cache_classes = true 
to your production.rb (or development.rb for testing), this seems to catch all the models for caching.

79 out of 100 based on 59 user ratings 409 reviews