From d6bf62c3c6be07dd4208214f86b8b122b4f3d16a Mon Sep 17 00:00:00 2001 From: Adam Konner Date: Mon, 13 May 2013 13:14:46 -0400 Subject: fix grammar --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index fcfc54a3d7..ceb1859c2f 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -1065,8 +1065,8 @@ with foreign key constraints in the database. Although Active Record does not provide any tools for working directly with such features, the `execute` method can be used to execute arbitrary SQL. You -could also use some gem like -[foreigner](https://github.com/matthuhiggins/foreigner) which add foreign key +can also use a gem like +[foreigner](https://github.com/matthuhiggins/foreigner) which adds foreign key support to Active Record (including support for dumping foreign keys in `db/schema.rb`). -- cgit v1.2.3 From 4d88e85d98639b4ea6ec7e67b8c5a52422199b0f Mon Sep 17 00:00:00 2001 From: Mikhail Dieterle Date: Tue, 14 May 2013 21:04:32 +0300 Subject: Use new hash syntax --- guides/source/migrations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index ceb1859c2f..550f8fdc3c 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -852,7 +852,7 @@ end # app/models/product.rb class Product < ActiveRecord::Base - validates :flag, :inclusion => { :in => [true, false] } + validates :flag, inclusion: { in: [true, false] } end ``` @@ -877,7 +877,7 @@ end # app/models/product.rb class Product < ActiveRecord::Base - validates :flag, :inclusion => { :in => [true, false] } + validates :flag, inclusion: { in: [true, false] } validates :fuzz, presence: true end ``` -- cgit v1.2.3 From 5554775980b27b64a5ae5810cabc4886776b9206 Mon Sep 17 00:00:00 2001 From: Radu Busuioc Date: Thu, 16 May 2013 18:46:00 +0100 Subject: Corrected documentation regarding validation errors --- guides/source/active_record_validations.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index dfc951f10e..621d2222ff 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -162,8 +162,8 @@ Person.create(name: nil).valid? # => false ``` After Active Record has performed validations, any errors found can be accessed -through the `errors` instance method, which returns a collection of errors. By -definition, an object is valid if this collection is empty after running +through the `errors.messages` instance method, which returns a collection of errors. +By definition, an object is valid if this collection is empty after running validations. Note that an object instantiated with `new` will not report errors even if it's @@ -176,17 +176,17 @@ end >> p = Person.new #=> # ->> p.errors +>> p.errors.messages #=> {} >> p.valid? #=> false ->> p.errors +>> p.errors.messages #=> {name:["can't be blank"]} >> p = Person.create #=> # ->> p.errors +>> p.errors.messages #=> {name:["can't be blank"]} >> p.save @@ -993,12 +993,12 @@ end person = Person.new person.valid? # => false -person.errors +person.errors.messages # => {:name=>["can't be blank", "is too short (minimum is 3 characters)"]} person = Person.new(name: "John Doe") person.valid? # => true -person.errors # => [] +person.errors.messages # => {} ``` ### `errors[]` -- cgit v1.2.3