Skip to content

Instantly share code, notes, and snippets.

@dxg
Created June 8, 2010 02:56
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 dxg/429539 to your computer and use it in GitHub Desktop.
Save dxg/429539 to your computer and use it in GitHub Desktop.
DATAMAPPER = 'git://github.com/datamapper'
DM_VERSION = '~> 1.0.0.rc3'
DO_VERSION = '~> 0.10.3'
gem 'dm-sqlite-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-sqlite-adapter.git"
gem 'dm-validations', DM_VERSION, :git => "#{DATAMAPPER}/dm-validations"
gem 'dm-constraints', DM_VERSION, :git => "#{DATAMAPPER}/dm-constraints"
gem 'dm-aggregates', DM_VERSION, :git => "#{DATAMAPPER}/dm-aggregates"
gem 'dm-is-list', DM_VERSION, :git => "#{DATAMAPPER}/dm-is-list"
gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter"
gem 'dm-active_model', DM_VERSION, :git => "#{DATAMAPPER}/dm-active_model"
gem 'data_objects', DO_VERSION, :git => "#{DATAMAPPER}/do.git"
gem 'do_sqlite3', DO_VERSION, :git => "#{DATAMAPPER}/do.git"
require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require :default
DataMapper.setup(:default, 'sqlite3::memory:')
class Candy
include DataMapper::Resource
include DataMapper::Validate
property :id, Serial
property :name, String, :length => 1..20
is :list
end
Candy.auto_migrate!
c = Candy.new
if c.save
puts 'Saved'
else
# this gives: 'Position must not be blank'
puts 'Could not save because:'
puts ' ' + c.errors.full_messages.join("\n ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment