is it possible to use 2 types of database in a Rails application?
I am using 2 databases – Postgres to store data which might not change much, and MongoDB
to store data which change dynamically.
is this valid approach? and is it possible to connect between these 2 databases and operate
in a single Rails application?
Please correct, if i am wrong.
regards,
Balan
Found solution :
We can use
mongoidgem to achieve this.Steps to install
1) Install mongoid by adding
"gem mongoid"in Gemfile and runningbundlecommand2) Generate mongoid configuration by typing
"rails g mongoid:config", this will create aconfig file
mongoid.ymlneardatabase.ymlfile, you can add the configuration to Mongo serverin this file.
Note : After adding Mongoid, all the models created will be created for MongoDB by default, you can specify
--ormoption to generate Models for Postgres.