1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix quotes and ruby old hashes

This commit is contained in:
Mikhail Dieterle 2013-06-15 18:39:17 +03:00
parent d4794fd9d2
commit 1010f9382b

View file

@ -1736,15 +1736,15 @@ If you want to make sure that, upon insertion, all of the records in the
persisted association are distinct (so that you can be sure that when you
inspect the association that you will never find duplicate records), you should
add a unique index on the table itself. For example, if you have a table named
``person_posts`` and you want to make sure all the posts are unique, you could
`person_posts` and you want to make sure all the posts are unique, you could
add the following in a migration:
```ruby
add_index :person_posts, :post, :unique => true
add_index :person_posts, :post, unique: true
```
Note that checking for uniqueness using something like ``include?`` is subject
to race conditions. Do not attempt to use ``include?`` to enforce distinctness
Note that checking for uniqueness using something like `include?` is subject
to race conditions. Do not attempt to use `include?` to enforce distinctness
in an association. For instance, using the post example from above, the
following code would be racy because multiple users could be attempting this
at the same time: