2021-10-24 07:10:30 +00:00
|
|
|
class Api::V1::Accounts::Contacts::NotesController < Api::V1::Accounts::Contacts::BaseController
|
|
|
|
before_action :note, except: [:index, :create]
|
|
|
|
|
|
|
|
def index
|
2021-10-25 13:05:58 +00:00
|
|
|
@notes = @contact.notes.latest.includes(:user)
|
2021-10-24 07:10:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@note = @contact.notes.create!(note_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2022-03-24 07:58:25 +00:00
|
|
|
@note.destroy!
|
2021-10-24 07:10:30 +00:00
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@note.update(note_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def note
|
|
|
|
@note ||= @contact.notes.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def note_params
|
|
|
|
params.require(:note).permit(:content).merge({ contact_id: @contact.id, user_id: Current.user.id })
|
|
|
|
end
|
|
|
|
end
|