Skip to content

Instantly share code, notes, and snippets.

@kiko
Created February 13, 2009 08:38
Show Gist options
  • Save kiko/63801 to your computer and use it in GitHub Desktop.
Save kiko/63801 to your computer and use it in GitHub Desktop.
> ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
> cat validate_test.rb
require 'not_naughty'
Person = Struct.new(:name) do
extend NotNaughty
validates(:name) { presence and length :minimum => 4 }
end
Person.new('Horst').valid? # => true
Person.new('Foo').valid? # => false
> ruby validate_test.rb
validate_test.rb:5: undefined local variable or method `presence' for #<NotNaughty::ClassMethods::Builder:0xb7a5ce60> (NameError)
from /home/kiko/projects/others/not-naughty/lib/not_naughty/class_methods.rb:23:in `instance_eval'
from /home/kiko/projects/others/not-naughty/lib/not_naughty/class_methods.rb:23:in `validates'
from validate_test.rb:5
from validate_test.rb:3:in `new'
from validate_test.rb:3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment