开发者

How to add support for additional ORM for a Rails 3.1 engine?

I just created a super simple Rails 3.1 engine https://github.com/millisami/mero_cms and it works.

It only supports ActiveRecord. Now I want to add additional or just MongoId ORM to make it a little agnostic.

Since devise supports MongoId too, I looked at its code but my expertise couldn't figure out the moving ruby parts.

So, is there anything/post elsewhere开发者_如何学C or explanation on how to add user configurable ORM MongoId support too?


after you installed Devise, you should be able to find a devise.rb under your app/config/initializers/, find

# ==> ORM configuration

and put

require 'devise/orm/mongoid'

under it.

That shall do the magic. The latest Mongoid gem will automatically install the generators so that when you call something like

rails g model User name:string it will generate Mongoid specific model for you.

A better start point is to just use Rails 3 template from github:

https://github.com/RailsApps/rails3-application-templates

It's just a simple command like:

rails new APP_NAME -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-devise-template.rb -T -O

and you're all set!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜