If you’re using reflection_on_association with ActiveRecord and need to use it with MongoMapper, here is what you want to do:
undefined method `reflect_on_association' for User:Class
ActiveRecord:
User.reflect_on_association(:posts).klass.new
MongoMapper:
User.associations[:posts].klass.new
Mongoid:
User.associations['posts'].klass.new
notice the posts is a string, it will not work with a symbol
UPDATE – (Apr 2011) Mongoid now follows ActiveRecord’s style naming:
User.reflect_on_association(:posts).klass.new
Last night I was trying really hard to get MongoMapper to work with Paperclip via GridFS and failed. It seems right now Paperclip or even CarrierWave are not ready to be used with the latest MongoMapper drivers and GridFS (and I needed to use the latest drivers due to Scopify).
After giving up using GridFS, I wanted to use Paperclip with MongoMapper with the normal file system and I found this article from Ben Curtis, however with the latest version of Paperclip (version 2.3.1.1) and MongoMapper (version 0.7.6) I was unsuccessful, kept getting:
Anonymous modules have no name to be referenced by
After reading the backtrace and diving into the paperclip source code I noticed that it was trying to use the ActiveRecord.logger and since I’ve removed ActiveRecord from my app, it was failing (with the odd error).
After some tweaking of Ben’s code, I came up with this: http://gist.github.com/424158
Learn More