This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
pat (author)
Sat Apr 07 16:10:52 -0700 2007
| name | age | message | |
|---|---|---|---|
| |
README | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
Rakefile | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
init.rb | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
install.rb | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
lib/ | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
spec/ | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
tasks/ | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
| |
uninstall.rb | Fri Jan 26 19:15:08 -0800 2007 | [pat] |
README
InstanceValidations
===================
ActiveRecord lets you define validations at the class level. This plugin lets you define validations for ActiveRecord
instances. Take the following ActiveRecord class:
class Chicken < ActiveRecord::Base
include InstanceValidations
# Has two columns, name and home_town. Only validate name
validates_presence_of :name
end
All instances of Chicken will require a name in order to be valid. If you don't define any instance validations, you'll
get the expected behavior:
chicken = Chicken.new
chicken.valid? => false, will have an error on name
If you do specify instance validations, the class validations are ignored and only instance validations are used:
chicken_without_a_name = Chicken.new
class << chicken_without_a_name
validates_presence_of :home_town
end
chicken_without_a_name.valid? # => false, will have an error on home_town but not name
chicken_without_a_name.home_town = "Roostershire"
chicken_without_a_name.valid? # => true
Written by Pat Maddox. Released under the MIT License.
svn://evang.eli.st/public/plugins/instance_validations




