Sha256: a75b5cbc4eda83d910c99ea182ee389fe405aea2da5f16e791529e7ac7e5c2ce
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'datamapper' DataMapper.setup(:default, 'sqlite::memory:') module DataMapperModels class User include DataMapper::Resource property :username, String, :key => true validates_presence_of :username validates_uniqueness_of :username end class Post include DataMapper::Resource property :id, Serial property :title, String, :required => false property :body, Text, :required => false has n, :comments belongs_to :author, :model => User, :required => false has n, :tags, :through => Resource end class Comment include DataMapper::Resource property :id, Serial property :body, Text, :required => false belongs_to :post, :required => false end class Tag include DataMapper::Resource property :id, Serial property :name, Text, :required => false has n, :posts, :through => Resource, :required => false end module DataMapperEnvironment def empty_database! [User, Post, Comment].each do |klass| klass.all.destroy klass.clear_blueprints! end end end end DataMapper.auto_migrate!
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm-machinist-0.0.1 | spec/support/data_mapper_environment.rb |