Specify association dependency
This commit is contained in:
parent
d8942bfd31
commit
be8d1d1ce2
2 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Reference in a new issue