This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
/
patients_controller.rb
84 lines (71 loc) · 1.94 KB
/
patients_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class PatientsController < ApplicationController
# GET /patients
# GET /patients.json
def index
@patients = Patient.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @patients }
end
end
# GET /patients/1
# GET /patients/1.json
def show
@patient = Patient.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @patient }
end
end
# GET /patients/new
# GET /patients/new.json
def new
@patient = Patient.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @patient }
end
end
# GET /patients/1/edit
def edit
@patient = Patient.find(params[:id])
end
# POST /patients
# POST /patients.json
def create
@patient = Patient.new(params[:patient])
respond_to do |format|
if @patient.save
format.html { redirect_to @patient, notice: 'Patient was successfully created.' }
format.json { render json: @patient, status: :created, location: @patient }
else
format.html { render action: "new" }
format.json { render json: @patient.errors, status: :unprocessable_entity }
end
end
end
# PUT /patients/1
# PUT /patients/1.json
def update
@patient = Patient.find(params[:id])
respond_to do |format|
if @patient.update_attributes(params[:patient])
format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @patient.errors, status: :unprocessable_entity }
end
end
end
# DELETE /patients/1
# DELETE /patients/1.json
def destroy
@patient = Patient.find(params[:id])
@patient.destroy
respond_to do |format|
format.html { redirect_to patients_url }
format.json { head :no_content }
end
end
end