diff options
author | schneems <richard.schneeman@gmail.com> | 2016-06-07 10:35:54 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2016-06-08 08:59:51 -0500 |
commit | 05b7c415c86a4f22e60493bdf3d962227fc0a020 (patch) | |
tree | 1f3ddb068e759710510121a948fbcb34a67277dc /guides/source | |
parent | 3fc5577363dc4049cd1d0bba8f3fa9296f1ced57 (diff) | |
download | rails-05b7c415c86a4f22e60493bdf3d962227fc0a020.tar.gz rails-05b7c415c86a4f22e60493bdf3d962227fc0a020.tar.bz2 rails-05b7c415c86a4f22e60493bdf3d962227fc0a020.zip |
[ci skip] Expand information on message options
Link to the more detailed message documentation when using a message option in validations.
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. |