Validates Xor Presence Of plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.pluginaweek.org/trunk/plugins/active_record/validations/validates_xor_presence_of/
Description
===============
Sometimes your model is defined such that it is only valid if exactly one of a series of attributes is present. For example, a person's location may be defined by a known region (a region_id referencing a regions table) or a custom region (an unknown region). In this case, you may have two columns in your table: region_id and custom_region. If this is the case, validates_xor_presence_of helps ensure that exactly 1 or those 2 attributes is present at any time.
Usage
==========
Example
----------------------
class Person < ActiveRecord::Base validates_xor_presence_of :region_id, :custom_region, :on => :create end
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago

