質問編集履歴
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -114,7 +114,7 @@
|
|
114
114
|
|
115
115
|
def update
|
116
116
|
|
117
|
-
@record = @user.records.find_by(date: params[:date])
|
117
|
+
@record = @user.records.find_by(date: params[:record][:date])
|
118
118
|
|
119
119
|
if @record.update_attributes(record_params)
|
120
120
|
|
@@ -248,7 +248,7 @@
|
|
248
248
|
|
249
249
|
<%= f.label :n_dbp, for: "inputN_DBP", class: "sr-only" %>
|
250
250
|
|
251
|
-
<%= f.telephone_field :n_
|
251
|
+
<%= f.telephone_field :n_dbp, placeholder: "最低血圧", class: "form-control", id: "inputN_DBP", value: @record.n_dbp %>
|
252
252
|
|
253
253
|
</div>
|
254
254
|
|
@@ -256,7 +256,7 @@
|
|
256
256
|
|
257
257
|
<%= f.label :n_pulse, for: "inputN_PLS", class: "sr-only" %>
|
258
258
|
|
259
|
-
<%= f.telephone_field :n_s
|
259
|
+
<%= f.telephone_field :n_pulse, placeholder: "脈拍", class: "form-control", id: "inputN_PLS", value: @record.n_pulse %>
|
260
260
|
|
261
261
|
</div>
|
262
262
|
|
1
exists?の使い方を間違えていたので、new_record?にして書き直しました。(結果は同じで、更新ができません。)
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,29 +76,51 @@
|
|
76
76
|
|
77
77
|
@record = @user.records.find_by(date: default_day)
|
78
78
|
|
79
|
-
if @record.e
|
79
|
+
if @record.new_record?
|
80
|
+
|
81
|
+
@record = Record.new(date: default_day)
|
82
|
+
|
83
|
+
else
|
80
84
|
|
81
85
|
@record = @user.records.find_by(date: default_day)
|
82
86
|
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
def create
|
94
|
+
|
95
|
+
@record = Record.new(record_params)
|
96
|
+
|
97
|
+
if @record.save
|
98
|
+
|
99
|
+
redirect_to root_url
|
100
|
+
|
101
|
+
flash[:notice] = 'Record was successfully created.'
|
102
|
+
|
83
103
|
else
|
84
104
|
|
85
|
-
|
105
|
+
flash.now[:danger] = 'errored!'
|
106
|
+
|
86
|
-
|
107
|
+
render 'new'
|
108
|
+
|
87
|
-
end
|
109
|
+
end
|
88
|
-
|
110
|
+
|
89
|
-
end
|
111
|
+
end
|
90
|
-
|
91
|
-
|
92
|
-
|
112
|
+
|
113
|
+
|
114
|
+
|
93
|
-
def
|
115
|
+
def update
|
116
|
+
|
94
|
-
|
117
|
+
@record = @user.records.find_by(date: params[:date])
|
118
|
+
|
95
|
-
@record
|
119
|
+
if @record.update_attributes(record_params)
|
96
|
-
|
97
|
-
if @record.save
|
98
120
|
|
99
121
|
redirect_to root_url
|
100
122
|
|
101
|
-
flash[:notice] = 'Record was successfully
|
123
|
+
flash[:notice] = 'Record was successfully updated.'
|
102
124
|
|
103
125
|
else
|
104
126
|
|
@@ -112,41 +134,19 @@
|
|
112
134
|
|
113
135
|
|
114
136
|
|
115
|
-
def update
|
116
|
-
|
117
|
-
@record = @user.records.find_by(date: params[:date])
|
118
|
-
|
119
|
-
if @record.update_attributes(record_params)
|
120
|
-
|
121
|
-
redirect_to root_url
|
122
|
-
|
123
|
-
flash[:notice] = 'Record was successfully updated.'
|
124
|
-
|
125
|
-
else
|
126
|
-
|
127
|
-
flash.now[:danger] = 'errored!'
|
128
|
-
|
129
|
-
render 'new'
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
|
137
137
|
def search
|
138
138
|
|
139
139
|
@user = current_user
|
140
140
|
|
141
141
|
@record = @user.records.where("date = ?", params[:date])
|
142
142
|
|
143
|
-
if @record.e
|
143
|
+
if @record.new_record?
|
144
|
+
|
145
|
+
@record = Record.new
|
144
146
|
|
145
147
|
render json: @record
|
146
148
|
|
147
|
-
else
|
149
|
+
else
|
148
|
-
|
149
|
-
@record = Record.new
|
150
150
|
|
151
151
|
render json: @record
|
152
152
|
|