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
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Product | |
include Mongoid::Document | |
field :name | |
references_many :categories, :stored_as => :array |
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
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Person | |
include Mongoid::Document | |
embeds_many :addresses | |
collection.remove |
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
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Publisher | |
include Mongoid::Document | |
field :stuff, :type => Hash | |
collection.remove |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Foo | |
include Mongoid::Document |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Person | |
include Mongoid::Document | |
collection.remove |
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
# .... | |
describe "#build" do | |
context "when the parent is new" do | |
let(:movie) { Movie.new } | |
let!(:rating) { movie.ratings.build } | |
it "appends the document to the association" do | |
movie.ratings.first.should == rating | |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Inventory | |
include Mongoid::Document |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Person | |
include Mongoid::Document # ... fields ... | |
field :name |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
config.autocreate_indexes = true | |
end | |
class User | |
include Mongoid::Document |
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
require 'mongoid' | |
require 'rspec' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
config.autocreate_indexes = true | |
end | |
class TaskGroupWorker | |
include Mongoid::Document |