I am curious how to setup both mongodb and redis for a single rails3 app? I googled but nothing found. any good idea? Thanks.
-
sorry, but what is the problem with this?Andrei Andrushkevich– Andrei Andrushkevich2011-04-18 16:35:12 +00:00Commented Apr 18, 2011 at 16:35
-
MongoDB and Redis are different data storage engines. In general, an application writes to a single data storage engine. What exactly are you trying to do? Write all data to both? Write some data to one and some data to the other?Gates VP– Gates VP2011-04-18 23:37:13 +00:00Commented Apr 18, 2011 at 23:37
2 Answers
Both mongo and redis have excellent ruby clients that can be used within rails3. You could create a rails project excluding the creation of activerecord and simply use instances of models created with either the mongo or redis client. I have actually used ohm for something similar for redis with rails and highly recommend it.
Comments
For setting up Mongo with Rails, take a look at MongoMapper. MongoDB got a great guide on MongoMapper and Rails aswell. When creating a Rails project, just remember not to include ActiveRecord. You can do that with the rails new my_app --skip-active-record switch. This is all mentioned in the guide, you should give it a read.
For Redis, I'm not sure what your use case is. Most common ones for Rails are things like Resque. You should first take a look at the Redis.io website. Then take a look at the redis-rb Ruby gem, it's really quite simple.