-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Coin
include Mongoid::Document
has_and_belongs_to_many :boxes
validates :boxes, presence: true
end
class Box
include Mongoid::Document
has_and_belongs_to_many :coins
end
>> 2.times
{ Coin.create }>> Box.create
{ coins: [Coin.first,Coin.last] }When I type Coin.first.boxes and Coin.last.boxes it returns "nil" in both cases instead of the box i have just created.
This behaviour disappears by removing the validation in Coin, then it behaves as expected.
(Using ruby 2.0)