質問編集履歴
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,12 +3,16 @@
|
|
3
3
|
その投稿されたものをindex.htmlで表示させたいのですが、うまくいきません。
|
4
4
|
|
5
5
|
コントローラー
|
6
|
+
※@postに毎回、画像を入れてるから、上書きされてる形になってるのではないかと思います
|
6
7
|
```ここに言語を入力
|
7
8
|
def new
|
8
9
|
@post = Post.new
|
9
10
|
end
|
10
11
|
|
11
12
|
def create
|
13
|
+
@post = Post.new(
|
14
|
+
image_name: params[:image],
|
15
|
+
)
|
12
16
|
@post = Post.new(image_name: params[:image])
|
13
17
|
if params[:image]
|
14
18
|
@post.image_name = "#{@post.id}.jpg"
|
@@ -23,6 +27,12 @@
|
|
23
27
|
<input name="image" type="file">
|
24
28
|
<% end %>
|
25
29
|
```
|
30
|
+
new.index.html
|
31
|
+
```ここに言語を入力
|
32
|
+
<%= form_tag("/posts/#{@post.id}/create", {multipart: true}) do %>
|
33
|
+
<input name="image" type="file">
|
34
|
+
<% end %>
|
35
|
+
```
|
26
36
|
上記コードでは
|
27
37
|
・newコントローラーで空のインスタンスを作る。
|
28
38
|
・new.index.html(name="image")で読み込んだ画像が、params[:image]にはいっている
|
@@ -36,7 +46,7 @@
|
|
36
46
|
↓
|
37
47
|
B画像の読み無処理をすると
|
38
48
|
↓
|
39
|
-
表示されるのはB画像ではなくA画像になってる。
|
49
|
+
表示されるのはB画像ではなくA画像になってる。(上書きのイメージ)
|
40
50
|
です。
|
41
51
|
たぶん、うまく、params[:image]にはいっていないのかな?と思います。。
|
42
52
|
すごくあいまいなままに覚えてます。
|
2
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
ruby on railsの"
|
1
|
+
ruby on railsの"開発環境"で 画像の取り込みがうまくいきません。
|
body
CHANGED
File without changes
|
1
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
ruby on rails
|
1
|
+
ruby on railsの"本番環境"で 画像の取り込みがうまくいきません。
|
body
CHANGED
File without changes
|