Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Created March 21, 2011 02:38
Show Gist options
  • Save MarkMenard/878934 to your computer and use it in GitHub Desktop.
Save MarkMenard/878934 to your computer and use it in GitHub Desktop.
class FooBar
include Mongoid::Document
field :query_subject, :type => String
field :content, :type => String
class << self
def find_current (query_subject)
self.where(:query_subject => query_subject).order_by(:created_at.desc).first
end
end
end
class HtmlDocument < FooBar
extend DocWrapperHelpers
def to_dom
@html_dom ||= Nokogiri::HTML(content)
end
end
class SpyOnWebDocument < HtmlDocument
doc_wrapper DocWrappers::SpyOnWebDocWrapper
doc_wrapper_property :adsense_domains
end
When I populate the adsense data # features/step_definitions/worker_steps.rb:24
Access to the collection for SpyOnWebDocument is not allowed since it is an embedded document, please access a collection from the root document. (Mongoid::Errors::InvalidCollection)
org/jruby/RubyKernel.java:2038:in `send'
./app/models/foo_bar.rb:9:in `find_current'
./app/services/find_or_create_service.rb:16:in `find_current'
./app/services/find_or_create_service.rb:12:in `execute'
./app/services/populator.rb:31:in `find_or_create_source_document'
./app/services/populator.rb:17:in `execute'
./features/step_definitions/worker_steps.rb:29:in `(root)':in `/^I populate the adsense data$/'
features/workers/populate_adsense.feature:12:in `When I populate the adsense data'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment