Forward: This post is mainly copypasta from an answer I wrote on StackOverflow. It also takes into account the version of Mongoid being used predates the includes method. The includes method being the suggested best practice for the problem now. includes will be mentioned at the bottom of the post. Take me to the current best practice. How to deal with n+1 issues utilizing identity maps: What is the n+1 issue?

Continue reading

In the apps I’ve been working on recently I decided to utilize rails built in authentication ‘has_secure_password’ which began shipping with Rails 3.1. Has_secure_password is simple to use and doesn’t bring in any extra bulk. With some of these projects I also decided to use MongoDB & Mongoid. When trying to use the has_secure_password method I got: undefined local variable or method `has_secure_password' for User:Class (NameError) Solution: You must include include ActiveModel::SecurePassword.

Continue reading

While setting up a new Rails development environment I ran into the error bson keys must be strings or symbols. After some googling I found the following method to fix it: /gems/bson-1.2.0/lib/bson/bson_c.rb:24:in `serialize': keys must be strings or symbols (TypeError) rvm gemset empty bundle install /fixed

Continue reading

Author's picture

Brian Pearce

Software Developer, Endurance Cyclist,
Rubiest, Rustacean, and Gopher

Software Engineer

Barcelona, Spain