Created
April 6, 2011 02:55
-
-
Save tal/905046 to your computer and use it in GitHub Desktop.
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
| >> m = Match.first | |
| => #<Match _id: 4d9bce2458f68fbb67000001, user_ids: [1, 2], _id: BSON::ObjectId('4d9bce2458f68fbb67000001'), _type: nil> | |
| >> m.players.create(:user_id => 1) | |
| NoMethodError: undefined method `name' for nil:NilClass |
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 Match | |
| include Mongoid::Document | |
| field :user_ids, :type => Array, :default => [] | |
| embeds_many :players | |
| end |
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 Player | |
| include Mongoid::Document | |
| field :first_name, :type => String | |
| field :score, :type => Float, :default => 0.0 | |
| field :user_id, :type => Integer | |
| embedded_in :match, :inverse_of => :matches | |
| embeds_many :points | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment