I am just trying to walk through this tutorial
http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html#redis_and_rails
And when I put this code in lib/user.rb or app/models/user.rb:
class User < ActiveRecord::Base
# follow a user
def follow!(user)
@redis.multi do
...
I get this error:
ActiveRecord::StatementInvalid: Could not find table 'users'
from /Users/jeremysmith/.rvm/gems/ruby-1.9.2-p180/gems/activerecord- 3.0.5/lib/active_record/connection_adapters/sqlite_adapter.rb:295:in `table_structure'
Note that @redis is working, and I’m not using sqlite at all, so I’m not sure why it is being referenced. I do have sqlite included in my Gemfile, but it is nowhere else in my project.
You would still require a normal sqlite / mysql database to store your users, it’s just certain parts that you are storing in redis. Make sure you have the proper migrations and issue a
rake db:migrate.I also noticed you used
@redisinstead of$redisare you sure that’s working as expected?