質問編集履歴
2
エラー文の修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
railsでファイルダウンロードする際のTypeError (no implicit conversion of ImagesUploader into String)
|
1
|
+
しゅうrailsでファイルダウンロードする際のTypeError (no implicit conversion of ImagesUploader into String)
|
test
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
stat = File::stat(filepath)
|
70
70
|
|
71
|
-
send_file(filepath, :filename => @
|
71
|
+
send_file(filepath, :filename => @attachment.file.url.gsub(/.*//,''), :length => stat.size)
|
72
72
|
|
73
73
|
end
|
74
74
|
|
@@ -76,13 +76,13 @@
|
|
76
76
|
|
77
77
|
def view
|
78
78
|
|
79
|
-
@a
|
79
|
+
@upload_file = UploadFile.find(params[:id].to_i)
|
80
80
|
|
81
81
|
filepath = @attachment.file.current_path
|
82
82
|
|
83
83
|
stat = File::stat(filepath)
|
84
84
|
|
85
|
-
send_file(filepath, :filename =>
|
85
|
+
send_file(filepath, :filename => @attachment.file.url.gsub(/.*//,''), :length => stat.size, :disposition => 'inline')
|
86
86
|
|
87
87
|
end
|
88
88
|
|
@@ -154,7 +154,7 @@
|
|
154
154
|
|
155
155
|
```
|
156
156
|
|
157
|
-
TypeError (no implicit conversion of
|
157
|
+
TypeError (no implicit conversion of nil into String):
|
158
158
|
|
159
159
|
|
160
160
|
|
1
19行目のエラーを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -147,3 +147,29 @@
|
|
147
147
|
<% end %>
|
148
148
|
|
149
149
|
```
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
エラーメッセージ
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
TypeError (no implicit conversion of ImagesUploader into String):
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
app/controllers/mypage/attachments_controller.rb:19:in `stat'
|
162
|
+
|
163
|
+
app/controllers/mypage/attachments_controller.rb:19:in `download'
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
対象エラー箇所
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
stat = File::stat(filepath)
|
174
|
+
|
175
|
+
```
|