Created
November 19, 2010 21:40
-
-
Save kernow/707239 to your computer and use it in GitHub Desktop.
mongoid key issue
This file contains hidden or 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 Car | |
include Mongoid::Document | |
field :name | |
field :colour | |
key :name | |
end | |
c1 = Car.new :name => 'bob', :colour => 'red' | |
c1.save # returns true | |
c2 = Car.new :name => 'bob', :colour => 'blue' | |
c2.save # returns true | |
Car.all.count # returns 1 | |
Car.first.name # returns 'bob' | |
Car.first.colour # returns 'red' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment