Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created September 27, 2009 15:54
Show Gist options
  • Select an option

  • Save knowtheory/194831 to your computer and use it in GitHub Desktop.

Select an option

Save knowtheory/194831 to your computer and use it in GitHub Desktop.
require 'dm-core'
require 'dm-aggregates'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://localhost/dm_specs")
class CrawledPage
include DataMapper::Resource
property :id, Serial
belongs_to :crawling_run
end
class CrawlingRun
include DataMapper::Resource
property :id, Serial
belongs_to :board_account
has n, :crawled_pages
end
class BoardAccount
include DataMapper::Resource
property :id, Serial
belongs_to :board
belongs_to :recruiter, :nullable => true
has n, :crawling_runs
end
class Recruiter
include DataMapper::Resource
property :id, Serial
has n, :board_accounts
end
DataMapper.auto_migrate!
CrawledPage.count('crawling_run.board_account.board_id' => 'board1') # pulled from email and explodes
CrawledPage.count('crawling_run.board_account.recruiter.id' => 'board1') # works
CrawledPage.count('crawling_run.board_account.id' => 'board1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment