public
Description: Dave Hoover's stuff
Homepage: http://redsquirrel.com/dave
Clone URL: git://github.com/redsquirrel/nest.git
Search Repo:
nest / validation_killer
name age message
..
folder README.txt Sat Jul 26 00:22:35 -0700 2008 Tweaking documentation [Dave Hoover]
folder validation_killer.rb Sat Jul 26 00:05:54 -0700 2008 Adding the glorious validation killer [Dave Hoover]
folder validation_killer_test.rb Sat Jul 26 00:05:54 -0700 2008 Adding the glorious validation killer [Dave Hoover]
README.txt
Validation Killer can be useful for opening up third-party ActiveRecord::Base models and redefining validations.  
Currently this means you'll need to blow away all the validations and redefine the ones you want.

So, let's say you're using some models that shouldn't be touched...

class User < ActiveRecord::Base
  validates_presence_of :name
  validates_confirmation_of :email
end

...but you need to change some of these validations.  Grab validation killer and require it...

require 'validation_killer'

User.new(:name => "Dave").valid?  # false, wants an email

User.class_eval
  clear_all_validations
  validates_presence_of :name
end

User.new(:name => "Dave").valid?  # true, only cares about name


CREDITS

Brought to you by Dave Hoover, inspired by Nate Jackson, who will probably take this and make it better.
We work at Obtiva's Software Studio.