質問編集履歴

1

不足箇所の追記

2020/07/20 10:27

投稿

BKBKB
BKBKB

スコア8

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,11 @@
14
14
 
15
15
  しかし、作成したインスタンス```document_create```を確認すると(4行目)、```image: nil```となっており、保存ができません。
16
16
 
17
+
18
+
17
- ```ターミナル
19
+ ターミナル
20
+
21
+ ```
18
22
 
19
23
  [1] pry(#<SearchesController>)> params
20
24
 
@@ -25,6 +29,148 @@
25
29
  => #<Document:0x00007f8287a3b0e0 id: nil, date: 20200201, author: "田中", image: nil, company_id: 96, item_id: 56, created_at: nil, updated_at: nil, user_id: 1>
26
30
 
27
31
 
32
+
33
+ ```
34
+
35
+ ストロングパラメータ
36
+
37
+ ```
38
+
39
+ def document_params
40
+
41
+ params.require(:document).permit(:date, :author, :image).merge(company_id: @company_id, item_id: @item_id, user_id: current_user.id)
42
+
43
+ end
44
+
45
+ ```
46
+
47
+
48
+
49
+ new.html.erb
50
+
51
+ ```
52
+
53
+ <div class="form">
54
+
55
+ <div class="search_new_head">
56
+
57
+ <div class="search_new_home">
58
+
59
+ <%= link_to "", searches_path(current_user), class: "fas fa-home" %>
60
+
61
+ </div>
62
+
63
+ 納入仕様書登録
64
+
65
+ </div>
66
+
67
+ <div class="notifications">
68
+
69
+ <% flash.each do |key, value| %>
70
+
71
+ <%= content_tag(:div, value, class: key) %>
72
+
73
+ <% end %>
74
+
75
+ </div>
76
+
77
+ <div class="search_new_content">
78
+
79
+ <%= form_for @company, html: { multipart: true }, url: searches_path, local: true do |f| %>
80
+
81
+ <div class="search_new_content__company">
82
+
83
+ <div class="search_new_content__element">
84
+
85
+ 会社名<br>
86
+
87
+ <%= f.text_field :name %>
88
+
89
+ </div>
90
+
91
+ <div class="search_new_content__element">
92
+
93
+ 事業所<br>
94
+
95
+ <%= f.text_field :office %>
96
+
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+
103
+ <%= fields_for @item do |c| %>
104
+
105
+ <div class="search_new_content__item">
106
+
107
+ <div class="search_new_content__element">
108
+
109
+ 製品名<br>
110
+
111
+ <%= c.text_field :name %>
112
+
113
+ </div>
114
+
115
+ <div class="search_new_content__element">
116
+
117
+ コード<br>
118
+
119
+ <%= c.text_field :code %>
120
+
121
+ </div>
122
+
123
+ </div>
124
+
125
+
126
+
127
+ <%= fields_for @document do |d| %>
128
+
129
+ <div class="search_new_content__document">
130
+
131
+ <div class="search_new_content__element">
132
+
133
+ 締結日(例 20200101)<br>
134
+
135
+ <%= d.text_field :date %>
136
+
137
+ </div>
138
+
139
+ <div class="search_new_content__element">
140
+
141
+ 投稿者<br>
142
+
143
+ <%= d.text_field :author %>
144
+
145
+ </div>
146
+
147
+ <div class="search_new_content__element">
148
+
149
+ 納入仕様書<br>
150
+
151
+ <%= d.file_field :image %>
152
+
153
+ </div>
154
+
155
+ </div>
156
+
157
+ <div class="search_new_content__element">
158
+
159
+ <br>
160
+
161
+ <%= f.submit " 登録 "%>
162
+
163
+ </div>
164
+
165
+ <% end %>
166
+
167
+ <% end %>
168
+
169
+ <% end %>
170
+
171
+ </div>
172
+
173
+ </div>
28
174
 
29
175
  ```
30
176