diff options
author | Xavier Noria <fxn@hashref.com> | 2009-04-18 16:26:36 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2009-04-18 16:26:36 +0200 |
commit | b82f3bcf39c5c6cea8461219b322563c6be5c132 (patch) | |
tree | adf0a65911c184f7f9d9ff664465e29bb1385712 /railties/guides/source | |
parent | a8a5b17df076bcc40fbd12b68148016120856dcb (diff) | |
download | rails-b82f3bcf39c5c6cea8461219b322563c6be5c132.tar.gz rails-b82f3bcf39c5c6cea8461219b322563c6be5c132.tar.bz2 rails-b82f3bcf39c5c6cea8461219b322563c6be5c132.zip |
fixes email/radio mismatch reported by Marek in LH
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/activerecord_validations_callbacks.textile | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/guides/source/activerecord_validations_callbacks.textile b/railties/guides/source/activerecord_validations_callbacks.textile index 5ae4884297..218125e35f 100644 --- a/railties/guides/source/activerecord_validations_callbacks.textile +++ b/railties/guides/source/activerecord_validations_callbacks.textile @@ -530,11 +530,11 @@ class Invoice < ActiveRecord::Base end </ruby> -You can even create your own validation helpers and reuse them in several different models. Here is an example where we create a custom validation helper to validate the format of fields that represent email addresses: +You can even create your own validation helpers and reuse them in several different models. For example, an application that manages surveys may find useful to express that a certain field corresponds to a set of choices: <ruby> ActiveRecord::Base.class_eval do - def self.validates_as_radio(attr_name, n, options={}) + def self.validates_as_choice(attr_name, n, options={}) validates_inclusion_of attr_name, {:in => 1..n}.merge(options) end end @@ -544,7 +544,7 @@ Simply reopen +ActiveRecord::Base+ and define a class method like that. You'd ty <ruby> class Movie < ActiveRecord::Base - validates_as_radio :rating, 5 + validates_as_choice :rating, 5 end </ruby> |