diff options
author | Richard Schneeman <richard.schneeman@gmail.com> | 2016-06-08 15:08:32 -0500 |
---|---|---|
committer | Richard Schneeman <richard.schneeman@gmail.com> | 2016-06-08 15:08:32 -0500 |
commit | 154f11663e2fca684e7c6d14d3dffa79b82cb84f (patch) | |
tree | ac41a58fddd3f1aa24d23b2ad2fd4aceec8955fb /guides/source | |
parent | b24b9e27510e97ed9878abb2458640f32a48f655 (diff) | |
parent | 05b7c415c86a4f22e60493bdf3d962227fc0a020 (diff) | |
download | rails-154f11663e2fca684e7c6d14d3dffa79b82cb84f.tar.gz rails-154f11663e2fca684e7c6d14d3dffa79b82cb84f.tar.bz2 rails-154f11663e2fca684e7c6d14d3dffa79b82cb84f.zip |
Merge pull request #25315 from schneems/schneems/inclusion-doc
[ci skip] Expand information on message options
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_record_validations.md | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 936d6a30b8..2737237c1a 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -392,7 +392,8 @@ The `exclusion` helper has an option `:in` that receives the set of values that will not be accepted for the validated attributes. The `:in` option has an alias called `:within` that you can use for the same purpose, if you'd like to. This example uses the `:message` option to show how you can include the -attribute's value. +attribute's value. For full options to the message argument please see the +[message documentation](#message). The default error message is _"is reserved"_. @@ -427,7 +428,8 @@ end The `inclusion` helper has an option `:in` that receives the set of values that will be accepted. The `:in` option has an alias called `:within` that you can use for the same purpose, if you'd like to. The previous example uses the -`:message` option to show how you can include the attribute's value. +`:message` option to show how you can include the attribute's value. For full +options please see the [message documentation](#message). The default error message for this helper is _"is not included in the list"_. @@ -768,6 +770,9 @@ class Coffee < ApplicationRecord end ``` +For full options to the message argument please see the +[message documentation](#message). + ### `:allow_blank` The `:allow_blank` option is similar to the `:allow_nil` option. This option @@ -792,7 +797,8 @@ for each validation helper. The `:message` option accepts a `String` or `Proc`. A `String` `:message` value can optionally contain any/all of `%{value}`, `%{attribute}`, and `%{model}` which will be dynamically replaced when -validation fails. +validation fails. This replacement is done using the I18n gem, and the +placeholders must match exactly, no spaces are allowed. A `Proc` `:message` value is given two arguments: the object being validated, and a hash with `:model`, `:attribute`, and `:value` key-value pairs. |