machinist_mongo icon indicating copy to clipboard operation
machinist_mongo copied to clipboard

I can't use associations with mongo_mapper

Open weldyss opened this issue 13 years ago • 2 comments

I've created blueprint with Product and Item following these models

class Item include MongoMapper::EmbeddedDocument belongs_to :product end

class Product include MongoMapper::Document many :items end

And blueprints.rb

Item.blueprint do product { Product.make } quantity (1..10).to_a.shuffle.first.to_i total 5 * quantity end

I receive this error when tests running:

undefined method `each' for #Product:0x007f90324dde28

weldyss avatar Sep 04 '11 23:09 weldyss

Maybe because embedded documents no have association resources?

weldyss avatar Sep 05 '11 00:09 weldyss

OH WAIT!! This doesn't work only in my test environment. I tested in rails console and works fine :S

weldyss avatar Sep 05 '11 00:09 weldyss