aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_validations.md
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-06-17 10:47:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-06-17 10:47:08 -0700
commit252d11321f8ca0c47111304ffe37d9bf69cad77b (patch)
tree301a28faa688f421a353df15cc16f1ae558e8deb /guides/source/active_record_validations.md
parent89c9ff8d8b70bb5b0bc56576be94f27f87996bbe (diff)
parentad707a1f16dea6a93f37feed711ec0b51c2d3ab6 (diff)
downloadrails-252d11321f8ca0c47111304ffe37d9bf69cad77b.tar.gz
rails-252d11321f8ca0c47111304ffe37d9bf69cad77b.tar.bz2
rails-252d11321f8ca0c47111304ffe37d9bf69cad77b.zip
Merge branch 'master' into mrbrdo-fixserialization
* master: (142 commits) Use Colspan in th Tags Added test for link_to_unless to make sure the result consistency. Escape the string even when the condition of link_to_unless is not satisfied. Add CHANGELOG entry for #10969 Use a case insensitive URI Regexp for #asset_path collection tags accept html attributes as the last element of collection Rewind StringIO instances before be parsed again Use xml instead already parsed xml Updated the doc for const_regexp [ci skip] Make test name descriptive and add reference to original regression commit fixture setup does not rely on `AR::Base.configurations`. regression test + mysql2 adapter raises correct error if conn is closed. cleanup, remove trailing whitespace from AR changelog 'json' gem is no more required under JRuby fix typos Fix AS changelog [ci skip] Update the HTML boolean attributes per the HTML 5.1 spec Changing const_regexp to check for constant name. valid_app_const? -> valid_const? Add CHANGELOG entry for #10740 ...
Diffstat (limited to 'guides/source/active_record_validations.md')
-rw-r--r--guides/source/active_record_validations.md12
1 files changed, 6 insertions, 6 deletions
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index 621d2222ff..37790c62b1 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -243,7 +243,7 @@ line of code you can add the same kind of validation to several attributes.
All of them accept the `:on` and `:message` options, which define when the
validation should be run and what message should be added to the `errors`
collection if it fails, respectively. The `:on` option takes one of the values
-`:save` (the default), `:create` or `:update`. There is a default error
+`:save` (the default), `:create` or `:update`. There is a default error
message for each one of the validation helpers. These messages are used when
the `:message` option isn't specified. Let's take a look at each one of the
available helpers.
@@ -357,7 +357,7 @@ given regular expression, which is specified using the `:with` option.
```ruby
class Product < ActiveRecord::Base
validates :legacy_code, format: { with: /\A[a-zA-Z]+\z/,
- message: "Only letters allowed" }
+ message: "only allows letters" }
end
```
@@ -677,13 +677,13 @@ class GoodnessValidator
def initialize(person)
@person = person
end
-
+
def validate
if some_complex_condition_involving_ivars_and_private_methods?
@person.errors[:base] << "This person is evil"
end
end
-
+
# …
end
```
@@ -736,8 +736,8 @@ class Topic < ActiveRecord::Base
validates :title, length: { is: 5 }, allow_blank: true
end
-Topic.create("title" => "").valid? # => true
-Topic.create("title" => nil).valid? # => true
+Topic.create(title: "").valid? # => true
+Topic.create(title: nil).valid? # => true
```
### `:message`