Skip to content

Instantly share code, notes, and snippets.

@jimmys
Created February 2, 2011 07:14
Show Gist options
  • Save jimmys/807356 to your computer and use it in GitHub Desktop.
Save jimmys/807356 to your computer and use it in GitHub Desktop.
Demonstrates a problem I am having with associations in datamapper
#! /usr/bin/env ruby
require 'dm-core'
class Foo
include DataMapper::Resource
property :id, Serial
has n, :foo_bars
has n, :bars, through: :foo_bars
end
class Bar
include DataMapper::Resource
property :id, Serial
has n, :foo_bars
has n, :foos, through: :foo_bars
end
class FooBar
include DataMapper::Resource
property :foo_id, Integer, key: true, min: 1
property :bar_id, Integer, key: true, min: 1
belongs_to :foo, key: true
belongs_to :bar, key: true
end
DataMapper.finalize
# works...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment