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:
Pranav Raj S
2020-08-23 00:05:07 +05:30
committed by GitHub
parent ec6cd4bbba
commit 8cf05f1d9f
23 changed files with 709 additions and 133 deletions

View File

@@ -20,6 +20,11 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
def update
@contact.update!(contact_update_params)
rescue ActiveRecord::RecordInvalid => e
render json: {
message: e.record.errors.full_messages.join(', '),
contact: Contact.find_by(email: contact_params[:email])
}, status: :unprocessable_entity
end
def search
@@ -43,7 +48,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
end
def contact_params
params.require(:contact).permit(:name, :email, :phone_number, custom_attributes: {})
params.require(:contact).permit(:name, :email, :phone_number, additional_attributes: {}, custom_attributes: {})
end
def contact_custom_attributes