fix bugs when supporting mongoid