Created
November 2, 2009 01:27
-
-
Save scottjbarr/223866 to your computer and use it in GitHub Desktop.
Mongoid error on save
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
require 'mongoid' | |
class Person < Mongoid::Document | |
field :title | |
field :name | |
field :age | |
has_many :addresses | |
end | |
class Address < Mongoid::Document | |
field :street | |
field :city | |
field :state | |
field :post_code | |
belongs_to :person | |
end | |
Mongoid.connect_to("mongoid-test") | |
person = Person.new(:title => 'Mr', :name => 'Guy Mandood', :age => 22) | |
person.save! | |
a = Address.new | |
a.street = 'Orchard Rd' | |
a.city = 'Singapore' | |
a.state = 'Singapore' | |
a.person = person | |
a.save! # Exception here, see below | |
#/usr/local/lib/ruby19/gems/1.9.1/gems/mongoid-0.6.1/lib/mongoid/commands/save.rb:16:in `execute': undefined method #`save' for nil:NilClass (NoMethodError) | |
# from /usr/local/lib/ruby19/gems/1.9.1/gems/mongoid-0.6.1/lib/mongoid/commands.rb:55:in `save!' | |
# from ./mongoid_test.rb:30:in `<main>' |
Wow, thats an one. I seem to remember a version of the mongoid gem had an
issue... ? Sorry I can't be more specific, I would just be making things up.
…On Fri, May 27, 2011 at 11:01 AM, RooSoft < ***@***.***>wrote:
I'm having the same problem with Mongoid 2.0... have you solved it?
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/223866
I think I am using the latest...
Well, thanks anyway! :)
On Thu, May 26, 2011 at 11:12 PM, scottbarr <
[email protected]>wrote:
… Wow, thats an one. I seem to remember a version of the mongoid gem had an
issue... ? Sorry I can't be more specific, I would just be making things
up.
On Fri, May 27, 2011 at 11:01 AM, RooSoft <
***@***.***>wrote:
> I'm having the same problem with Mongoid 2.0... have you solved it?
> ##
>
> Reply to this email directly or view it on GitHub:
> https://gist.github.com/223866
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/223866
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having the same problem with Mongoid 2.0... have you solved it?