diff options
Diffstat (limited to 'guides/source/active_record_validations.md')
-rw-r--r-- | guides/source/active_record_validations.md | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 1c1b863fe9..546c0608ee 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -427,7 +427,7 @@ class Essay < ActiveRecord::Base validates :content, length: { minimum: 300, maximum: 400, - tokenizer: lambda { |str| str.scan(/\w+/) }, + tokenizer: lambda { |str| str.split(/\s+/) }, too_short: "must have at least %{count} words", too_long: "must have at most %{count} words" } @@ -533,6 +533,7 @@ validates :boolean_field_name, presence: true validates :boolean_field_name, inclusion: { in: [true, false] } validates :boolean_field_name, exclusion: { in: [nil] } ``` + By using one of these validations, you will ensure the value will NOT be `nil` which would result in a `NULL` value in most cases. |