Rails 3: how to use active record and mongoid at the same time

后端 未结 1 2058
孤街浪徒
孤街浪徒 2020-12-14 04:42

I read alot that folks recommend using nosql together with sql datastores. For example have some reporting audit-trailing or log information in mysql and some threaded hiera

相关标签:
1条回答
  • 2020-12-14 05:12

    Well, to do it, you're supposed to leave Rails intact, so don't exclude libraries like it's commonly suggested in Mongoid documentation. You need to configure them separately, so you need to have a database.yml and mongo.yml config files and you need to make sure they're both getting loaded.

    After that, you can enable/disable AR and Mongoid on a per-model basis.

    class User < ActiveRecord::Base
      #this is an AR model
    end
    
    class Item
      include Mongoid::Document
      #this is a Mongoid model
    end
    
    0 讨论(0)
提交回复
热议问题