質問編集履歴

3

変更

2018/02/14 11:33

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- しん画像を指定した時間後に非表示にする
1
+ 指定した時間後に非表示にする
test CHANGED
@@ -52,118 +52,6 @@
52
52
 
53
53
 
54
54
 
55
- ```
56
-
57
- product/index
58
-
59
-
60
-
61
- <% @products.each do |product| %>
62
-
63
- <div class="col-xs-12">
64
-
65
- <%= attachment_image_tag product, :image , class: "product_image" %>
66
-
67
- </div>
68
-
69
- <% end %>
70
-
71
-
72
-
73
- ```
74
-
75
-
76
-
77
- ```
78
-
79
- create_table "products", force: :cascade do |t|
80
-
81
- t.integer "user_id"
82
-
83
- t.string "image_id"
84
-
85
- t.datetime "created_at", null: false
86
-
87
- t.datetime "updated_at", null: false
88
-
89
- end
90
-
91
- ```
92
-
93
-
94
-
95
- ```
96
-
97
- 貼りたい画像(NEW)場所
98
-
99
- app/assets/images/NEW.jpg
100
-
101
- ```
102
-
103
-
104
-
105
-
106
-
107
- 追加分
108
-
109
-
110
-
111
- ```
112
-
113
- class AddFilenameToImages < ActiveRecord::Migration[5.1]
114
-
115
- def change
116
-
117
- add_column :images, :filename, :string
118
-
119
- end
120
-
121
- end
122
-
123
- ```
124
-
125
-
126
-
127
- ```
128
-
129
- <% @products.each do |product| %>
130
-
131
- <div class="col-xs-12">
132
-
133
- <% if product.is_new %>
134
-
135
- <%= attachment_image_tag product, :image , class: "product_image" %>
136
-
137
- このimageは商品のイメージです。
138
-
139
- </div>
140
-
141
- <% end %>
142
-
143
- <% end %>
144
-
145
- ```
146
-
147
-
148
-
149
- ```
150
-
151
-
152
-
153
- create_table "images", force: :cascade do |t|
154
-
155
- t.datetime "created_at", null: false
156
-
157
- t.datetime "updated_at", null: false
158
-
159
- t.string "filename"
160
-
161
- end
162
-
163
- ```
164
-
165
-
166
-
167
55
 
168
56
 
169
57
  現状こんな感じなのですがNoMethodError in Products#indexと出てしまいます。

2

更新

2018/02/14 11:32

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 画像を指定した時間後に非表示にする
1
+ しん画像を指定した時間後に非表示にする
test CHANGED
@@ -99,3 +99,73 @@
99
99
  app/assets/images/NEW.jpg
100
100
 
101
101
  ```
102
+
103
+
104
+
105
+
106
+
107
+ 追加分
108
+
109
+
110
+
111
+ ```
112
+
113
+ class AddFilenameToImages < ActiveRecord::Migration[5.1]
114
+
115
+ def change
116
+
117
+ add_column :images, :filename, :string
118
+
119
+ end
120
+
121
+ end
122
+
123
+ ```
124
+
125
+
126
+
127
+ ```
128
+
129
+ <% @products.each do |product| %>
130
+
131
+ <div class="col-xs-12">
132
+
133
+ <% if product.is_new %>
134
+
135
+ <%= attachment_image_tag product, :image , class: "product_image" %>
136
+
137
+ このimageは商品のイメージです。
138
+
139
+ </div>
140
+
141
+ <% end %>
142
+
143
+ <% end %>
144
+
145
+ ```
146
+
147
+
148
+
149
+ ```
150
+
151
+
152
+
153
+ create_table "images", force: :cascade do |t|
154
+
155
+ t.datetime "created_at", null: false
156
+
157
+ t.datetime "updated_at", null: false
158
+
159
+ t.string "filename"
160
+
161
+ end
162
+
163
+ ```
164
+
165
+
166
+
167
+
168
+
169
+ 現状こんな感じなのですがNoMethodError in Products#indexと出てしまいます。
170
+
171
+ どうしたら良いでしょうか?

1

変更

2018/02/14 02:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -3,3 +3,99 @@
3
3
 
4
4
 
5
5
  例、商品に新着っていう画像を3日だけつけたいです。
6
+
7
+
8
+
9
+ ```
10
+
11
+ def index
12
+
13
+ @productc = Product.all
14
+
15
+ end
16
+
17
+
18
+
19
+ def new
20
+
21
+ @product = Product.new
22
+
23
+ end
24
+
25
+
26
+
27
+ def create
28
+
29
+ @product = Product.new(product_params)
30
+
31
+ @product.user_id = current_user.id
32
+
33
+ @product.save
34
+
35
+ redirect_to products_path
36
+
37
+ end
38
+
39
+ ```
40
+
41
+
42
+
43
+ ```
44
+
45
+ def index
46
+
47
+ @productc = Product.all
48
+
49
+ end
50
+
51
+ ```
52
+
53
+
54
+
55
+ ```
56
+
57
+ product/index
58
+
59
+
60
+
61
+ <% @products.each do |product| %>
62
+
63
+ <div class="col-xs-12">
64
+
65
+ <%= attachment_image_tag product, :image , class: "product_image" %>
66
+
67
+ </div>
68
+
69
+ <% end %>
70
+
71
+
72
+
73
+ ```
74
+
75
+
76
+
77
+ ```
78
+
79
+ create_table "products", force: :cascade do |t|
80
+
81
+ t.integer "user_id"
82
+
83
+ t.string "image_id"
84
+
85
+ t.datetime "created_at", null: false
86
+
87
+ t.datetime "updated_at", null: false
88
+
89
+ end
90
+
91
+ ```
92
+
93
+
94
+
95
+ ```
96
+
97
+ 貼りたい画像(NEW)場所
98
+
99
+ app/assets/images/NEW.jpg
100
+
101
+ ```