Skip to content

Instantly share code, notes, and snippets.

@solnic
Created November 11, 2010 10:36
Show Gist options
  • Select an option

  • Save solnic/672322 to your computer and use it in GitHub Desktop.

Select an option

Save solnic/672322 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# encoding: utf-8
require 'dm-sqlite-adapter'
require 'dm-migrations'
require 'dm-validations'
DataMapper.setup :default, "sqlite::memory:"
class Ban
include DataMapper::Resource
property :id, Serial
belongs_to :user # required by default
has n, :users, :through => Resource
end
class User
include DataMapper::Resource
property :id, Serial
end
DataMapper.finalize
DataMapper.auto_migrate!
b = Ban.new
puts b.valid?
puts b.errors[:user_id].inspect
false
["User must not be blank"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment