Mongoid and ActiveRecord generators

别说谁变了你拦得住时间么 提交于 2020-01-01 05:23:04

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/8404001/mongoid-and-activerecord-generators

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!