質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,4 +18,47 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
validates_with RelistTimeValidator , on: :update
|
21
|
+
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```lang-<ruby>
|
30
|
+
#item model
|
31
|
+
validates :limit_day, timeliness: { on_or_after: :today, format: '%Y/%m/%d %H:%M' }, allow_blank: false, on: :item_update_by_user
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
#item controller
|
36
|
+
if @item.limit_check
|
37
|
+
respond_to do |format|
|
38
|
+
@item.attributes = {item_status_id: 1, limit_check: false}
|
39
|
+
if @item.save(context: :item_update_by_user)
|
40
|
+
format.html { redirect_to @item, notice: 'アイテムを再出品しました。' }
|
41
|
+
format.json { render :show, status: :ok, location: @item }
|
42
|
+
else
|
43
|
+
format.html { render :relist }
|
44
|
+
format.json { render json: @item.errors, status: :unprocessable_entity }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
else
|
48
|
+
respond_to do |format|
|
49
|
+
@item.attributes = {item_status_id: 1, limit_check: false}
|
50
|
+
if @item.save(context: :item_update_by_user)
|
51
|
+
format.html { redirect_to @item, notice: 'アイテムを編集しました。' }
|
52
|
+
format.json { render :show, status: :ok, location: @item }
|
53
|
+
else
|
54
|
+
format.html { render :edit }
|
55
|
+
format.json { render json: @item.errors, status: :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#form
|
62
|
+
<%= f.text_field :limit_day %>
|
63
|
+
|
21
64
|
```
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
管理画面はactiveadminを使用しています。
|
4
4
|
|
5
|
-
|
5
|
+
**item model**
|
6
6
|
```lang-<ruby>
|
7
7
|
#タイムリミットが過ぎていないアイテムを編集しようとした場合に作動する
|
8
8
|
|