71

I'm using MongoDB via Mongoid integration, as well as ActiveRecord in a project. I would like to generate migrations for active record, and Mongoid is the default when I run.

rails g migration

Any ideas how to specify AR as my default generator for migrations, models, etc?

Thanks!

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130

2 Answers2

116
rails g active_record:migration 
Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
  • 2
    Thanks. I was seeing a weird `error mongoid [not found]` and run the migration as `rails g active_record:migration ...` instead of just `rails g migration ...` worked ;) – Aldo 'xoen' Giambelluca Jan 19 '16 at 11:10
86

You can config to use ActiveRecord generators in your config/application.rb

config.generators do |g| 
  g.orm :active_record 
end
dima Ti
  • 861
  • 5
  • 3
  • 6
    Great tip! Complementing it, after this config, to invoke a mongoid generator, say for a model 'whatever', one would use: rails g mongoid:model whatever – Thiago Ganzarolli Aug 21 '12 at 21:56
  • 1
    I tried this in my Rails 4.2.2 app but it is not working, I have the same behavior with and without this. Any idea what I should check to make it working? – ZedTuX Dec 20 '17 at 14:24