Skip to content

Instantly share code, notes, and snippets.

@lusis
Created June 30, 2010 17:35
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lusis/458979 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "mysql://root@localhost/db_development")
class Tester
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true, :length => 75
property :email, String, :required => true, :length => 75
property :comments, Text
property :created_at, DateTime
has n, :skills
has n, :languages, :through => :skills
end
class Language
include DataMapper::Resource
property :id, Serial
property :name, String
property :created_at, DateTime
has n, :skills
has n, :testers, :through => :skills
end
class Skill
include DataMapper::Resource
property :language_id, Integer, :key => true
property :tester_id, Integer, :key => true
belongs_to :language
belongs_to :tester
end
DataMapper.auto_migrate!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment