0
0
Fork 0

Required foreign keys (#2003)

* Add `required: true` option to foreign column

* Fixes NoMethodError

```
> Favourite.new.valid?
NoMethodError: undefined method `reblog?' for nil:NilClass
```
This commit is contained in:
alpaca-tc 2017-04-17 22:54:33 +09:00 committed by Eugen
parent f8546ad5a2
commit 630de52fdd
5 changed files with 8 additions and 11 deletions

View file

@ -3,9 +3,8 @@
class Mute < ApplicationRecord
include Paginable
belongs_to :account
belongs_to :target_account, class_name: 'Account'
belongs_to :account, required: true
belongs_to :target_account, class_name: 'Account', required: true
validates :account, :target_account, presence: true
validates :account_id, uniqueness: { scope: :target_account_id }
end