Skip to content

Instantly share code, notes, and snippets.

@anlek
Created June 3, 2010 15:35
Show Gist options
  • Save anlek/424028 to your computer and use it in GitHub Desktop.
Save anlek/424028 to your computer and use it in GitHub Desktop.
u = User.new
u.images
NoMethodError: undefined method `images' for #<User:0x3666c98>
from /usr/local/lib/ruby/gems/1.8/gems/mongo_mapper-0.7.6/lib/mongo_mapper/plugins/dirty.rb:25:in `method_missing'
from (irb):9
u.user_images
=> []
class User
include MongoMapper::Document
many :user_images, :as => :images
end
class UserImage
include MongoMapper::EmbeddedDocument
key :source_file_name, String
end
@anlek
Copy link
Author

anlek commented Jun 4, 2010

For anyone who comes across this, the line:

many :user_images, :as => :images

should be:

many :images, :class_name => "UserImage"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment