Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoid and ActiveRecord generators

I have both ActiveRecord (MySQL) and Mongoid in my Rails 3.1 application. Everything is fine, excepts all generators uses mongoid to generate models. This way, when i:

rails g model user

i receive mongoid-like model, but i need ActiveRecord structure and migrations.

How can i switch back to AR?

like image 812
There Are Four Lights Avatar asked Dec 06 '11 17:12

There Are Four Lights


1 Answers

Mongoid overrides the model generator, but you can switch it back.

In config/application.rb you can either add a line if you've already got a block similar to this:

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

Or just simply add the entire config line directly to the file

config.generators.orm :active_record

You can also pass :migrations => false if you want to turn off migrations

like image 76
John Paul Ashenfelter Avatar answered Sep 28 '22 08:09

John Paul Ashenfelter