MongoMapper with Devise
I just ran across this error:
/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:239:in require': no such file to load -- devise/orm/mongo_mapper (LoadError)
and after searching through Google I really didn’t see anything that pointed to this problem since 2009, so I figured it was just me and I was just no cool enough to be in the know.
So here is my solution for all those people out there that are in the same boat as me ;) When connecting MongoMapper with Devise, there is one little change you must do to the devise initializer, when you set up mongo_mapper in the beginning you put all your connection information in a file more than likely named like one of the two below:
config/initializers/mongo.rb or config/initializers/mongo_mapper.rb
So when you run this command:
$bundle exec rails g devise:install
Devise adds another file to the initializers directory, in that file you will see this line: config/initializers/devise.rb
change it to below, and remember to use the name of the initializer that holds the mongodb connection information.
require 'mongo_mapper' # or 'mongo' whichever you said yes to for the initializer
$bundle exec rails g
and it should work with out any error of dependencies missing, assuming you installed everything right ;)
More Bash Laziness:
Add these lines to your bashrc or bash_profile if you use bundler, saves effort of typing too much:
alias br='bundle exec rails' alias brk='bundle exec rake' alias bi='bundle install'
and in case you for get all your alias (say cause you were on vacation), there is no reason you can’t build in a little cheatsheet.
alias aka='echo " br bundle exec rails brk bundle exec rake bi bundle install"'