Mongoid and ActiveRecord Generators

I have an ActiveRecord application (MySQL) and Mongoid in a Rails 3.1 application. Everything is fine, except that all generators use mongoid to generate models. So when i:

rails g model user 

I get a Mongoid model, but I need ActiveRecord structure and migrations.

How can I return to AR?

+6
source share
1 answer

Mongoid overrides the model generator, but you can return it.

In config / application.rb you can add a line if you already have a block similar to this:

 config.generators do |g| g.template_engine :haml ... g.orm :active_record end 

Or just just add the whole configuration line directly to the file

 config.generators.orm :active_record 

You can also pass: migrations => false if you want to disable migration

+8
source

Source: https://habr.com/ru/post/903212/


All Articles