-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I get a DocumentNotFound if I try to find a Site by its Id using Email.sites.find("withAValidID")
class Email include Mongoid::Document field :address, :type => String has_and_belongs_to_many :sites end class Site include Mongoid::Document field :name, :type => String has_many :pages has_and_belongs_to_many :emails end class Page include Mongoid::Document field :title, :type => String belongs_to :site end
this specs are red
describe Email do it "should be possible to find a referenced site by its id" do site = Site.create :name => "MyNewSite" site.emails.create :address => "myemail@email.com" email = Email.where(:address => "myemail@email.com").first email.sites.find(site.id.to_s).should eq site end end
just to be sure, that this feature is implemented - in 1-N reference it's green
describe Site do it "should be possible to find a referenced page by its id" do site = Site.create :name => "MyNewSite" page = site.pages.create :title => "MyFirstPage" site.pages.find(page.id.to_s).should eq page end end