回答編集履歴
5
参考情報であることを強調
test
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
```rb
|
8
|
+
|
9
|
+
# これは参考情報です
|
8
10
|
|
9
11
|
=> #<Image:0x00007fe2a605b191
|
10
12
|
|
@@ -18,7 +20,13 @@
|
|
18
20
|
|
19
21
|
|
20
22
|
|
23
|
+
|
24
|
+
|
21
|
-
|
25
|
+
# 下記は適宜質問者様の都合の良いModelに読み替えてください
|
26
|
+
|
27
|
+
# 今回の件で言えば、Product Model
|
28
|
+
|
29
|
+
class Image
|
22
30
|
|
23
31
|
def is_new
|
24
32
|
|
4
image_tagの使い方を追記
test
CHANGED
@@ -72,9 +72,11 @@
|
|
72
72
|
|
73
73
|
<% if product.is_new %>
|
74
74
|
|
75
|
-
<%=
|
75
|
+
<%= image_tag 'NEW' %>
|
76
76
|
|
77
77
|
<% end %>
|
78
|
+
|
79
|
+
<%= attachment_image_tag product, :image , class: "product_image" %>
|
78
80
|
|
79
81
|
</div>
|
80
82
|
|
3
if文の間違い修正
test
CHANGED
@@ -70,7 +70,7 @@
|
|
70
70
|
|
71
71
|
<div class="col-xs-12">
|
72
72
|
|
73
|
-
<%
|
73
|
+
<% if product.is_new %>
|
74
74
|
|
75
75
|
<%= attachment_image_tag product, :image , class: "product_image" %>
|
76
76
|
|
2
コメントの追加
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
class Image
|
21
|
+
class Image # ここは適宜質問者様の都合の良いモデルに読み替えてください
|
22
22
|
|
23
23
|
def is_new
|
24
24
|
|
1
どう実装したら良いのかに対しての追記
test
CHANGED
@@ -33,3 +33,51 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
このis_newをあとはview側で呼び出してあげるだけです
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
**追記**
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
修正前:
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```rb
|
48
|
+
|
49
|
+
<% @products.each do |product| %>
|
50
|
+
|
51
|
+
<div class="col-xs-12">
|
52
|
+
|
53
|
+
<%= attachment_image_tag product, :image , class: "product_image" %>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
修正後:
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```rb
|
68
|
+
|
69
|
+
<% @products.each do |product| %>
|
70
|
+
|
71
|
+
<div class="col-xs-12">
|
72
|
+
|
73
|
+
<%= if product.is_new %>
|
74
|
+
|
75
|
+
<%= attachment_image_tag product, :image , class: "product_image" %>
|
76
|
+
|
77
|
+
<% end %>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<% end %>
|
82
|
+
|
83
|
+
```
|