Created
April 30, 2010 17:44
-
-
Save jacquescrocker/385535 to your computer and use it in GitHub Desktop.
Revisions
-
railsjedi created this gist
Apr 30, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ require 'rubygems' require 'mongoid' Mongoid.configure do |config| config.master = Mongo::Connection.new.db("mongoid_key_test") end Mongoid.master.collection("users").drop class User include Mongoid::Document field :username key :username validates_uniqueness_of :username end 2.times do begin @user = User.create(:username => "Charles") # rescue => e # puts "ERROR!: #{e}" end if @user and [email protected]? puts "FAILED VALIDATION" puts @user.errors.inspect end end