Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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