Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Artist
- include Mongoid::Document
- field :name, type: String
- embeds_many :instruments
- end
- class Instrument
- include Mongoid::Document
- field :name, type: String
- embedded_in :artist
- end
- # Find the first artist named "Syd Vicious" and create an embedded bass
- # document for him. Of course he'll smash it within the next few minutes,
- # but no worries we can delete it later.
- Artist.where(name: "Syd Vicious").first.tap do |artist|
- artist.instruments.create(name: "Bass")
- end
Add Comment
Please, Sign In to add comment