diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-07-04 14:51:12 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-07-04 16:10:45 -0600 |
commit | 00f55516509770f58f9ce462d45afb80d8f649ca (patch) | |
tree | 800d823a63deec4d35e229cf43f547c038d9202a /activerecord/lib/active_record/associations/builder/has_one.rb | |
parent | a6cc7b0ebd608a5100df17b4cee182b67643baac (diff) | |
download | rails-00f55516509770f58f9ce462d45afb80d8f649ca.tar.gz rails-00f55516509770f58f9ce462d45afb80d8f649ca.tar.bz2 rails-00f55516509770f58f9ce462d45afb80d8f649ca.zip |
Add a `required` option to singular associations
In addition to defining the association, a `required` association will
also have its presence validated.
Before:
```ruby
belongs_to :account
validates_presence_of :account
```
After:
```ruby
belongs_to :account, required: true
```
This helps to draw a distinction between types of validations, since
validations on associations are generally for data integrity purposes,
and aren't usually set through form inputs.
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/has_one.rb')
0 files changed, 0 insertions, 0 deletions