diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2013-05-19 21:40:12 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2013-05-19 21:40:12 +0530 |
commit | d71b0935a956ebedea0bb975525fc0f5672e4088 (patch) | |
tree | ea512e13fd13dd144bdbf3469514beb8fba010c6 /guides | |
parent | d3d8cfd5689188f48714f49ad000a1c1fbd9edcd (diff) | |
parent | 7f24d3d6956a7775771302d143e3b09de681d12f (diff) | |
download | rails-d71b0935a956ebedea0bb975525fc0f5672e4088.tar.gz rails-d71b0935a956ebedea0bb975525fc0f5672e4088.tar.bz2 rails-d71b0935a956ebedea0bb975525fc0f5672e4088.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_record_validations.md | 14 | ||||
-rw-r--r-- | guides/source/migrations.md | 8 |
2 files changed, 11 insertions, 11 deletions
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 #=> #<Person id: nil, name: nil> ->> p.errors +>> p.errors.messages #=> {} >> p.valid? #=> false ->> p.errors +>> p.errors.messages #=> {name:["can't be blank"]} >> p = Person.create #=> #<Person id: nil, name: nil> ->> 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[]` diff --git a/guides/source/migrations.md b/guides/source/migrations.md index fcfc54a3d7..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 ``` @@ -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`). |