From c4634c0cf3940006dfd133d391702c2b9fcc5e54 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 11 Oct 2012 17:05:38 +0800 Subject: [PATCH] rails-models: update error helpers. --- rails-models.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rails-models.md b/rails-models.md index 495dab9b4..09e54588d 100644 --- a/rails-models.md +++ b/rails-models.md @@ -171,6 +171,14 @@ Validation end end +### Errors + + record.errors.valid? #=> false + record.errors #=> { :name => ["can't be blank"] } + record.errors.messages #=> { :name => ["can't be blank"] } + + record.errors[:name].any? + API ---