73

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!

1
  • 2
    I think I answered this (cant really answer it for another 7 hours due to rep). rails g active_record:migration seems to get it Commented Jun 16, 2011 at 13:41

2 Answers 2

119
rails g active_record:migration 
Sign up to request clarification or add additional context in comments.

1 Comment

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 ;)
88

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

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

2 Comments

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
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.