Use both ActiveRecord and Mongoid in a Rails project
Use both ActiveRecord and Mongoid in a Rails project is easy. Add mongoid in Gemfile:
1 | gem 'mongoid', '~> 6.1.0' |
then bundle install
However, the mongoid
gem would change your default ORM adapter from ActiveRecord to Mongoid:
If you’re not sure which default adapter is you can try: rails g model
and check the output message
1 | Usage: |
So if you wanna generate a new model inherited from ActiveRecord:
1 | rails g model Manager --orm=active_record |
Notice: it’s active_record
instead of activerecord