aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2012-11-27 08:51:36 -0800
committerSteve Klabnik <steve@steveklabnik.com>2012-11-27 08:51:36 -0800
commitcfd324b4b68469ba3188e4b7ba8586e59b239693 (patch)
treeaa458207b1b6c94db62980a9a2fd57f3e8f67238
parentba2fed41613e02bb6cfc46c92ace00abb99ce313 (diff)
downloadrails-cfd324b4b68469ba3188e4b7ba8586e59b239693.tar.gz
rails-cfd324b4b68469ba3188e4b7ba8586e59b239693.tar.bz2
rails-cfd324b4b68469ba3188e4b7ba8586e59b239693.zip
Fix validation based on object not _id.
From https://github.com/rails/rails/issues/6161\#issuecomment-10750118
-rw-r--r--guides/source/active_record_validations_callbacks.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/guides/source/active_record_validations_callbacks.md b/guides/source/active_record_validations_callbacks.md
index eedcd9a342..3c6e459453 100644
--- a/guides/source/active_record_validations_callbacks.md
+++ b/guides/source/active_record_validations_callbacks.md
@@ -372,12 +372,12 @@ class Person < ActiveRecord::Base
end
```
-If you want to be sure that an association is present, you'll need to test whether the foreign key used to map the association is present, and not the associated object itself.
+If you want to be sure that an association is present, you'll need to test the associated object itself, and not whether the foreign key used to map the association is present:
```ruby
class LineItem < ActiveRecord::Base
belongs_to :order
- validates :order_id, presence: true
+ validates :order, presence: true
end
```