-
-
Save shawn42/6ccb1ddf92d2621cb172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
include Mongoid::Document | |
end | |
class Preference | |
include Mongoid::Document | |
end | |
shawn = Person.create | |
=> #<Person _id: 4d6d10867654aa7574000001, > | |
# add relationship | |
class Person | |
include Mongoid::Document | |
references_and_referenced_in_many :preferences | |
end | |
class Preference | |
include Mongoid::Document | |
references_and_referenced_in_many :people | |
end | |
# works fine with a new Person | |
Person.create.preferences << Preference.create | |
# a pre-existing persion blows up | |
Person.find("4d6d10867654aa7574000001").preferences << Preference.create | |
Person.first.preferences << Preference.create | |
# error from rc.5 | |
TypeError: can't dup NilClass | |
from org/jruby/RubyKernel.java:1874:in `dup' | |
from /Users/shawn42/.rvm/gems/jruby-1.6.0.RC2/gems/mongoid-2.0.0.rc.5/lib/mongoid/relations/builders/referenced/many_to_many.rb:18:in `build' | |
from /Users/shawn42/.rvm/gems/jruby-1.6.0.RC2/gems/mongoid-2.0.0.rc.5/lib/mongoid/relations/accessors.rb:59:in `create_relation' | |
from /Users/shawn42/.rvm/gems/jruby-1.6.0.RC2/gems/mongoid-2.0.0.rc.5/lib/mongoid/relations/accessors.rb:26:in `build' | |
from /Users/shawn42/.rvm/gems/jruby-1.6.0.RC2/gems/mongoid-2.0.0.rc.5/lib/mongoid/relations/accessors.rb:116:in `preferences' | |
from org/jruby/RubyProc.java:268:in `call' | |
# error from rc.7 | |
NoMethodError: You have a nil object when you didn't expect it! | |
You might have expected an instance of Array. | |
The error occurred while evaluating nil.<< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment