Add Follow.unfollowed_at
The active scopes is used indirectly in the dossier<->gestionnaire associations: the existing tests in dossier and gestionnaire just work™.
This commit is contained in:
parent
d417907f36
commit
be4c575622
5 changed files with 29 additions and 6 deletions
|
@ -2,10 +2,12 @@ class Follow < ApplicationRecord
|
|||
belongs_to :gestionnaire
|
||||
belongs_to :dossier
|
||||
|
||||
validates :gestionnaire_id, uniqueness: { scope: :dossier_id }
|
||||
validates :gestionnaire_id, uniqueness: { scope: [:dossier_id, :unfollowed_at] }
|
||||
|
||||
before_create :set_default_date
|
||||
|
||||
scope :active, -> { where(unfollowed_at: nil) }
|
||||
|
||||
private
|
||||
|
||||
def set_default_date
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue