Created
January 18, 2009 09:56
-
-
Save TheNicholasNick/48589 to your computer and use it in GitHub Desktop.
unique properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# A one file test to show ... | |
require 'rubygems' | |
gem('dm-core', '~> 0.9.8') | |
require 'dm-core' | |
require 'dm-validations' | |
# setup the logger | |
DataMapper::Logger.new(STDOUT, :debug) | |
# connect to the DB | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class TestModel | |
include DataMapper::Resource | |
# properties | |
property :id, Serial | |
property :login, String, :unique_index => :domain | |
property :domain, String, :unique_index => :domain | |
validates_is_unique :login, :scope => :domain | |
end | |
DataMapper.auto_migrate! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment