feat: Ability to edit a contact (#1092)
Ability to edit contact information in conversation sidebar Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -38,7 +38,7 @@ class Contact < ApplicationRecord
|
||||
has_many :inboxes, through: :contact_inboxes
|
||||
has_many :messages, as: :sender, dependent: :destroy
|
||||
|
||||
before_validation :downcase_email
|
||||
before_validation :prepare_email_attribute
|
||||
after_create_commit :dispatch_create_event
|
||||
after_update_commit :dispatch_update_event
|
||||
|
||||
@@ -69,9 +69,9 @@ class Contact < ApplicationRecord
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def downcase_email
|
||||
def prepare_email_attribute
|
||||
# So that the db unique constraint won't throw error when email is ''
|
||||
self.email = nil if email.blank?
|
||||
email.downcase! if email.present?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user