examples/recursive_find.rb in mongoid-dsl-1.0.1 vs examples/recursive_find.rb in mongoid-dsl-1.0.2
- old
+ new
@@ -1,72 +1,7 @@
require_relative "../lib/mongoid-dsl"
-require_relative "helper/con"
-
-:TestA.mongoid_name #> nil
-
-class TestA
-
- include Mongoid::Document
- include Mongoid::Timestamps
-
- store_in :collection => self.mongoid_name
-
- embeds_many :TestB.mongoid_name
-
- field :test,
- :type => String,
- :presence => true,
- :desc => "description for this field",
- :accept_only => %W[ hello world hello\ world ]
-
-end
-
-:TestA.mongoid_name #> "test_a"
-
-class TestB
-
- include Mongoid::Document
- include Mongoid::Timestamps
-
- embedded_in :TestA.mongoid_name
- embeds_many :TestC.mongoid_name
-
- field :test,
- :type => String,
- :presence => true,
- :desc => "description for this field",
- :uniq => true
-
-end
-
-class TestC
-
- include Mongoid::Document
- include Mongoid::Timestamps
-
- embedded_in :TestB.mongoid_name
- embeds_many :TestD.mongoid_name
-
- field :test,
- :type => String,
- :presence => true,
- :desc => "description for this field"
-
-end
-
-class TestD
-
- include Mongoid::Document
- include Mongoid::Timestamps
-
- embedded_in :TestC.mongoid_name
-
- field :test,
- :type => String,
- :presence => true,
- :desc => "description for this field"
-
-end
+require_relative "helper/connection"
+require_relative "helper/models"
test_a= TestA.create! test: "hello"
test_a.test_b.create(test: "world")
test_b= test_a.test_b.last
test_b.test_c.create(test: "world")