From 9cc7a1e04dc99dc47d11b6303fdb011532ce19b1 Mon Sep 17 00:00:00 2001 From: CassioMarques Date: Wed, 14 Jan 2009 22:22:56 -0200 Subject: Adding options for validates_numericality_of, adding author name with link at the end of the page --- .../html/activerecord_validations_callbacks.html | 43 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'railties/doc/guides/html/activerecord_validations_callbacks.html') diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index e1ede87403..61ccbbc1ca 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -612,6 +612,44 @@ http://www.gnu.org/software/src-highlite --> validates_numericality_of :points validates_numericality_of :games_played, :integer_only => true end +

Besides :only_integer, the validates_numericality_of helper also accepts the following options to add constraints to acceptable values:

+

The default error message for validates_numericality_of is "is not a number".

2.9. The validates_presence_of helper

This helper validates that the specified attributes are not empty. It uses the blank? method to check if the value is either nil or an empty string (if the string has only spaces, it will still be considered empty).

@@ -645,7 +683,7 @@ http://www.gnu.org/software/src-highlite --> Note -If you want to validate the presence of a boolean field (where the real values are true and false), you should use validates_inclusion_of :field_name, :in => [true, false] This is due to the way Object#blank? handles boolean values. false.blank? # => true +If you want to validate the presence of a boolean field (where the real values are true and false), you should use validates_inclusion_of :field_name, :in ⇒ [true, false] This is due to the way Object#blank? handles boolean values. false.blank? # ⇒ true

The default error message for validates_presence_of is "can’t be empty".

@@ -1351,7 +1389,8 @@ config.active_record14. Changelog -- cgit v1.2.3