Class: Renalware::Letters::ContactsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/letters/contacts_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
# File 'app/controllers/renalware/letters/contacts_controller.rb', line 19

def create
  contact = @patient.assign_contact(contact_params)
  if contact.save
    create_contact_successful(contact)
  else
    create_contact_failed(contact)
  end
end

#editObject



28
29
30
31
# File 'app/controllers/renalware/letters/contacts_controller.rb', line 28

def edit
  contact = patient.contacts.find(params[:id])
  render_edit(contact)
end

#indexObject



10
11
12
13
14
15
16
17
# File 'app/controllers/renalware/letters/contacts_controller.rb', line 10

def index
  render :index, locals: {
    patient: @patient,
    contact: build_contact,
    contact_descriptions: find_contact_descriptions,
    contacts: find_contacts
  }
end

#updateObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/renalware/letters/contacts_controller.rb', line 33

def update
  contact = patient.contacts.find(params[:id])
  if contact.update(update_contact_params)
    flash.now[:notice] = success_msg_for("contact")
    render locals: { patient: patient, contact: ContactPresenter.new(contact) }
  else
    render_edit(contact)
  end
end