質問編集履歴
1
コントローラー追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
また可能な場合、どのように記述すれば良いでしょうか?
|
5
5
|
宜しくお願い致します。
|
6
6
|
|
7
|
-
```
|
7
|
+
```new.html.erb
|
8
8
|
<div class="contents row">
|
9
9
|
<div class="container">
|
10
10
|
<h3>登録する</h3>
|
@@ -86,4 +86,37 @@
|
|
86
86
|
<% end %>
|
87
87
|
</div>
|
88
88
|
</div>
|
89
|
+
```
|
90
|
+
|
91
|
+
```records_contoroller.rb
|
92
|
+
class RecordsController < ApplicationController
|
93
|
+
before_action :authenticate_user!, only: :new
|
94
|
+
|
95
|
+
def index
|
96
|
+
@records = Record.includes(:user).order('created_at DESC')
|
97
|
+
end
|
98
|
+
|
99
|
+
def new
|
100
|
+
@record = Record.new
|
101
|
+
end
|
102
|
+
|
103
|
+
def create
|
104
|
+
@record = Record.new(record_params)
|
105
|
+
if @record.save
|
106
|
+
redirect_to root_path
|
107
|
+
else
|
108
|
+
render :new
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def show
|
113
|
+
@record = Record.find(params[:id])
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def record_params
|
119
|
+
params.require(:record).permit(:image, :onset_date, :onset_time, :visit_date, :hospital_name, :diagnosis, :cause, :prescription_drug, :remission_date, :memo, symptom: [], body_part: []).merge(user_id: current_user.id)
|
120
|
+
end
|
121
|
+
end
|
89
122
|
```
|