diff options
author | CassioMarques <cassiommc@gmail.com> | 2008-11-10 00:03:16 -0200 |
---|---|---|
committer | CassioMarques <cassiommc@gmail.com> | 2008-11-10 00:03:16 -0200 |
commit | 10c7c053a1cfee6f5c87a718bb6913adebaba9ba (patch) | |
tree | 99f9e231108c95e174d4a3c6d2b6a94fc33b24e2 /railties/doc/guides/source | |
parent | 0419efc1b9dc06c29d9b7b83ef84a6cf0fc500c2 (diff) | |
download | rails-10c7c053a1cfee6f5c87a718bb6913adebaba9ba.tar.gz rails-10c7c053a1cfee6f5c87a718bb6913adebaba9ba.tar.bz2 rails-10c7c053a1cfee6f5c87a718bb6913adebaba9ba.zip |
Added documentation for validates_inclusion_of
Diffstat (limited to 'railties/doc/guides/source')
-rw-r--r-- | railties/doc/guides/source/activerecord_validations_callbacks.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt index f61bea9d3d..4b4b9b4b17 100644 --- a/railties/doc/guides/source/activerecord_validations_callbacks.txt +++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt @@ -176,6 +176,19 @@ The default error message for +validates_format_of+ is "_is invalid_". === The +validates_inclusion_of+ helper +This helper validates that the attributes' values are included in a given set. In fact, this set can be any enumerable object. + +[source, ruby] +------------------------------------------------------------------ +class Coffee < ActiveRecord::Base + validates_inclusion_of :size, :in => %w(small medium large), :message => "%s is not a valid size" +end +------------------------------------------------------------------ + +The +validates_inclusion_of+ 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. In the previous example we used the +:message+ option to show how we can personalize it with the current attribute's value, through the +%s+ format mask. + +The default error message for +validates_inclusion_of+ is "_is not included in the list_". + === The +validates_length_of+ helper === The +validates_numericallity_of+ helper |