MongoMapper for Devise
mm-devise is intended for use with Rails 3 and Devise 1.1.5 and above. It may work with earlier versions of devise.
This README only covers mm-devise specifics. Make sure to read the devise README
The gem gives you the options of 2 ORM setups depending on what library you wish to use for validations:
- mongo_mapper - Uses MongoMapper validations
- mongo_mapper_active_model - Uses ActiveModel::Validations
The advantage to this is ActiveModel's I18n support for error messages, and it uses the same validations lib as devise does by default.
Currently only the
mongo_mapper option has been tested.
There should be full ActiveModel support in a future version of MongoMapper, after Rails 3 is released.
ActiveModel support will likely be part of MongoMapper 1.0 (as mentioned by jnunemaker in a post).
Add devise, mm-devise and MongoMapper gems to your Gemfile (your Rails app Gemfile). The following gems are required
gem 'mongo_mapper', '>= 0.9.0' gem 'jnunemaker-validatable', '>= 1.8.4' gem 'bson_ext', '>= 1.3' gem 'devise', '>= 1.2' gem 'mm-devise', '>= 1.2' # gem 'rails3-generators', '>= 0.14.0' # optional
You can install rails3-generators which includes a mongo_mapper Model generator
gem install rails3-generators
Alternatively use bundler to install all required gems in your Rails 3 app
Run the generator:
rails generate devise:install
The generator will install an initializer which describes ALL Devise's
configuration options and you MUST take a look at it. Make sure to specify
as the orm in the configuration file.
Note: The model generator should do this automatically.
To add Devise to any of your models using the generator:
rails generate mongo_mapper:devise MODEL
Example: create a User model for use with Devise
rails generate mongo_mapper:devise User
Read the README for devise at devise README
Test Driven Development - extending this project
To develop on this project using TDD, requires the following setup.
Clone this project into a container folder, fx
/projects, so you have fx
In the same container folder clone
devise from github
git clone http://github.com/kristianmandrup/mm-devise.git git clone http://github.com/plataformatec/devise.git cd mm-devise bundle install rake test
$ rake install
Gem release (push to RubyGems)
$ gem push pkg/mm-devis-xxxx.gem
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
bmarini - Updated to support MongoMapper 0.9 (June 2011) bhbryant - Fixed some issues and updated gem (Jan 2011) Jared Morgan - Created the dm-devise gem which was used as a template for the development of this gem. Also made suggestions for a few critical fixes and improvements in the code. Thanks :)
Bugs and Feedback
For mm-devise specific issues, please create an issue on GitHub at: mm-devise issues
Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.