Skip to content

Instantly share code, notes, and snippets.

@therabidbanana
Forked from jergason/gist:1041434
Created June 22, 2011 22:39
Show Gist options
  • Save therabidbanana/1041444 to your computer and use it in GitHub Desktop.
Save therabidbanana/1041444 to your computer and use it in GitHub Desktop.
Two has-and-belongs-to-many Properties to the same model
class Comparison
include DataMapper::Resource
property :id, Serial
has n, :msruns, :through => Resource
has n, :secondary_msruns, "Msrun", :through => SecondaryMsrunComparison, :via => :msrun
belongs_to :metric
end
class Msrun
include DataMapper::Resource
property :id, Serial, :key => true
has n, :comparisons, :through => Resource
has n, :secondary_comparisons, "Comparison", :through => SecondaryMsrunComparison, :via => :comparison
end
class SecondaryMsrunComparison
include DataMapper::Resource
belongs_to :msrun, :key => true
belongs_to :comparison, :key => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment