1
0
Fork 0

Specify association dependency

This commit is contained in:
Alex Kotov 2019-07-20 11:03:29 +05:00
parent d8942bfd31
commit be8d1d1ce2
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 3 additions and 1 deletions

View file

@ -21,7 +21,8 @@ class Person < ApplicationRecord
has_one :current_relationship,
-> { order(active_since: :desc) },
class_name: 'Relationship',
inverse_of: :person
inverse_of: :person,
dependent: :restrict_with_exception
has_many :person_comments, dependent: :restrict_with_exception

View file

@ -26,6 +26,7 @@ RSpec.describe Person do
have_one(:current_relationship)
.class_name('Relationship')
.inverse_of(:person)
.dependent(:restrict_with_exception)
.order(active_since: :desc)
end