質問編集履歴
4
mails_controller の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,7 +110,7 @@
|
|
110
110
|
|
111
111
|
if params[:attachments]
|
112
112
|
|
113
|
-
@mail.attachments =
|
113
|
+
@mail.attachments = "#{@mail.id}.jpg"
|
114
114
|
|
115
115
|
image = params[:attachments]
|
116
116
|
|
3
「mails_controller.rb」の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,7 +110,7 @@
|
|
110
110
|
|
111
111
|
if params[:attachments]
|
112
112
|
|
113
|
-
@mail.attachments =
|
113
|
+
@mail.attachments = params[:attachments].original_filename
|
114
114
|
|
115
115
|
image = params[:attachments]
|
116
116
|
|
2
`mails_controller.rb` の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,13 +98,25 @@
|
|
98
98
|
|
99
99
|
def create
|
100
100
|
|
101
|
+
@mails = Mail.all
|
102
|
+
|
101
|
-
#
|
103
|
+
# gemをインストールしてxlsxデータを出力できるようにする https://qiita.com/necojackarc/items/0dbd672b2888c30c5a38
|
102
|
-
|
104
|
+
|
103
|
-
@mail = Mail.new(dest: params[:dest], subject: params[:subject], body: params[:body]
|
105
|
+
@mail = Mail.new(dest: params[:dest], subject: params[:subject], body: params[:body])
|
104
106
|
|
105
107
|
@mail.save
|
106
108
|
|
109
|
+
|
110
|
+
|
111
|
+
if params[:attachments]
|
112
|
+
|
107
|
-
|
113
|
+
@mail.attachments ="#{@mail.id}.jpg"
|
114
|
+
|
115
|
+
image = params[:attachments]
|
116
|
+
|
117
|
+
File.binwrite("tmp/tests/#{@mail.id}.jpg", image.read)
|
118
|
+
|
119
|
+
end
|
108
120
|
|
109
121
|
end
|
110
122
|
|
1
`app/views/mails/index.html.erb` を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -169,3 +169,59 @@
|
|
169
169
|
|
170
170
|
|
171
171
|
```
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```Ruby
|
176
|
+
|
177
|
+
<!-- app/views/mails/index.html.erb -->
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<h1>送信内容一覧</h1>
|
182
|
+
|
183
|
+
<table border="1">
|
184
|
+
|
185
|
+
<thead>
|
186
|
+
|
187
|
+
<tr>
|
188
|
+
|
189
|
+
<th>id</th>
|
190
|
+
|
191
|
+
<th>送信先</th>
|
192
|
+
|
193
|
+
<th>タイトル</th>
|
194
|
+
|
195
|
+
<th>内容</th>
|
196
|
+
|
197
|
+
<th>添付ファイル</th>
|
198
|
+
|
199
|
+
<th></th>
|
200
|
+
|
201
|
+
</tr>
|
202
|
+
|
203
|
+
</thead>
|
204
|
+
|
205
|
+
<tbody>
|
206
|
+
|
207
|
+
<% @mails.each.with_index(1) do |mail, i| %> <!-- theadの上にあったのをここに移した-->
|
208
|
+
|
209
|
+
<tr>
|
210
|
+
|
211
|
+
<td><%= i %></td>
|
212
|
+
|
213
|
+
<td><%= mail.dest %></td>
|
214
|
+
|
215
|
+
<td><%= mail.subject %></td>
|
216
|
+
|
217
|
+
<td><%= mail.body %></td>
|
218
|
+
|
219
|
+
<td><%= mail.attachments %></td>
|
220
|
+
|
221
|
+
</tr>
|
222
|
+
|
223
|
+
<% end %> <!-- </table>の下にあったのをここに移した -->
|
224
|
+
|
225
|
+
</table>
|
226
|
+
|
227
|
+
```
|