Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created January 21, 2010 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoward/282674 to your computer and use it in GitHub Desktop.
Save ahoward/282674 to your computer and use it in GitHub Desktop.
irb(main):004:0> User.count
=> 2
irb(main):005:0> User.create(:email => nil)
=> #<User _id: 4b581254a047455f06000001, >
irb(main):006:0> User.create!(:email => nil)
=> #<User _id: 4b581258a047455f06000002, >
irb(main):007:0> User.create!(:email => nil)
=> #<User _id: 4b58125aa047455f06000003, >
irb(main):008:0> User.create!(:email => nil)
=> #<User _id: 4b58125ba047455f06000004, >
irb(main):009:0> User.count
=> 2
# hint - there is a unique index and NO WAY to ask mongoid to raise an error. it simply lies and returns an unsaved object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment