Skip to content

Instantly share code, notes, and snippets.

@andyhawthorne
Created November 25, 2012 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyhawthorne/4145614 to your computer and use it in GitHub Desktop.
Save andyhawthorne/4145614 to your computer and use it in GitHub Desktop.
class Category
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :notes
end
class Note
include DataMapper::Resource
property :id, Serial # An auto-increment integer key
property :category_id, Integer # An integer that acts as a foreign key
property :title, String # A varchar type string, for short strings
property :body, Text # A text block, for longer string data.
property :created_at, DateTime # A DateTime, for any date you might like.
belongs_to :category
end
DataMapper.finalize
DataMapper.auto_upgrade!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment