Skip to content

Commit

Permalink
Updated from the Upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
arbox committed Nov 11, 2016
1 parent 2546e81 commit 8bc343e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README-enUS.md
Expand Up @@ -803,8 +803,17 @@ when you need to retrieve a single record by some attributes.

```Ruby
# bad - application enforced default value
def amount
self[:amount] or 0
class Product < ActiveRecord::Base
def amount
self[:amount] || 0
end
end

# good - database enforced
class AddDefaultAmountToProducts < ActiveRecord::Migration
def change
change_column :products, :amount, :integer, default: 0
end
end
```

Expand Down Expand Up @@ -854,6 +863,7 @@ when you need to retrieve a single record by some attributes.
* <a name="meaningful-foreign-key-naming"></a>
Name your foreign keys explicitly instead of relying on Rails auto-generated
FK names. (http://edgeguides.rubyonrails.org/active_record_migrations.html#foreign-keys)
<sup>[[link](#meaningful-foreign-key-naming)]</sup>

```Ruby
# bad
Expand All @@ -871,8 +881,6 @@ when you need to retrieve a single record by some attributes.
end
```

<sup>[[link](#meaningful-foreign-key-naming)]</sup>

## Views

* <a name="no-direct-model-view"></a>
Expand Down

0 comments on commit 8bc343e

Please sign in to comment.