diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index e8889da408..2aa09ee125 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -245,6 +245,8 @@ ul#navMain {
  • The :allow_nil option
  • +
  • The :allow_blank option
  • +
  • The :message option
  • The :on option
  • @@ -696,9 +698,22 @@ http://www.gnu.org/software/src-highlite --> validates_inclusion_of :size, :in => %w(small medium large), :message => "%s is not a valid size", :allow_nil => true end -

    4.2. The :message option

    +

    4.2. The :allow_blank option

    +

    In compliment to :allow_nil we have :allow_blank. This option will let validation pass if the attribute’s value is nil or an empty string, i.e., any value that returns true for blank?.

    +
    +
    +
    class Topic < ActiveRecord::Base
    +  validates_length_of :title, :is => 5, :allow_blank => true
    +end
    +
    +Topic.create("title" => "").valid? # => true
    +Topic.create("title" => nil).valid? # => true
    +

    4.3. The :message option

    As stated before, the :message option lets you specify the message that will be added to the errors collection when validation fails. When this option is not used, Active Record will use the respective default error message for each validation helper.

    -

    4.3. The :on option

    +

    4.4. The :on option

    As stated before, the :on option lets you specify when the validation should happen. The default behaviour for all the built-in validation helpers is to be ran on save (both when you’re creating a new record and when you’re updating it). If you want to change it, you can use :on => :create to run the validation only when a new record is created or :on => :update to run the validation only when a record is updated.