Fixes for Rails 4

Hi! This commits fixes compatibility with current master branch of Mongoid gem (compatible with Rails 4). It may be a bit dirty, but looks like it works with both 3.x.x and master Mongoid versions.