Plugins - validates_existence

StarAdd to favorites

ValidatesExistence

============

This plugin adds a new validates_existence_of method to ActiveRecord::Base.

The validates_existence_of validator checks that a foreign key in a belongs_to association points to an exisiting record. If :allow_nil => true, then the key itself may be nil. A non-nil key requires that the foreign object must exist. Works with polymorphic belongs_to.

The default error message is "does not exist".

Example

=
  class Person < ActiveRecord::Base
    belongs_to :address
    validates_existence_of :address
  end

Copyright © 2007 Josh Susser, released under the MIT license

Josh Susser

http://blog.hasmanythrough.com/2007/7/14/validate-your-existence

http://svn.hasmanythrough.com/public/plugins/validates_existence/

Source-available-proprietary

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?