Skip to content

Instantly share code, notes, and snippets.

@merbjedi
Created March 31, 2010 02:11
Show Gist options
  • Save merbjedi/349850 to your computer and use it in GitHub Desktop.
Save merbjedi/349850 to your computer and use it in GitHub Desktop.
require "rubygems"
require "mongoid"
class Person
include Mongoid::Document
field :name
validate do
errors.add(:name, "NO NAME") if self.name.blank?
end
end
p = Person.new
p.save #=> true
p.errors #=> #<OrderedHash {:name=>["NO NAME"]}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment