Skip to content

Instantly share code, notes, and snippets.

@xrd
Created August 1, 2010 19:15
Show Gist options
  • Save xrd/503657 to your computer and use it in GitHub Desktop.
Save xrd/503657 to your computer and use it in GitHub Desktop.
# user.rb
class User
include DataMapper::Resource
# has_and_belongs_to_many :groups
has n, :groups, :through => Resource
has n, :links
property :id, Serial
property :email, String, :required => true, :length => 500
property :identifier, String, :required => true, :length => 500
property :username, String, :required => true, :length => 500
property :nickname, String, :required => true, :length => 500
property :photo, String, :required => true, :length => 500
timestamps :at
end
# group.rb
class Group
has n, :links
has n, :users, :through => Resource
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true, :length => 500
property :user_id, Integer, :required => true
timestamps :at
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment