質問編集履歴

2

追記

2015/06/23 06:57

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -39,3 +39,89 @@
39
39
  validates_with RelistTimeValidator , on: :update
40
40
 
41
41
  ```
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ ```lang-<ruby>
58
+
59
+ #item model
60
+
61
+ validates :limit_day, timeliness: { on_or_after: :today, format: '%Y/%m/%d %H:%M' }, allow_blank: false, on: :item_update_by_user
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+ #item controller
70
+
71
+ if @item.limit_check
72
+
73
+ respond_to do |format|
74
+
75
+ @item.attributes = {item_status_id: 1, limit_check: false}
76
+
77
+ if @item.save(context: :item_update_by_user)
78
+
79
+ format.html { redirect_to @item, notice: 'アイテムを再出品しました。' }
80
+
81
+ format.json { render :show, status: :ok, location: @item }
82
+
83
+ else
84
+
85
+ format.html { render :relist }
86
+
87
+ format.json { render json: @item.errors, status: :unprocessable_entity }
88
+
89
+ end
90
+
91
+ end
92
+
93
+ else
94
+
95
+ respond_to do |format|
96
+
97
+ @item.attributes = {item_status_id: 1, limit_check: false}
98
+
99
+ if @item.save(context: :item_update_by_user)
100
+
101
+ format.html { redirect_to @item, notice: 'アイテムを編集しました。' }
102
+
103
+ format.json { render :show, status: :ok, location: @item }
104
+
105
+ else
106
+
107
+ format.html { render :edit }
108
+
109
+ format.json { render json: @item.errors, status: :unprocessable_entity }
110
+
111
+ end
112
+
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
119
+
120
+
121
+ #form
122
+
123
+ <%= f.text_field :limit_day %>
124
+
125
+
126
+
127
+ ```

1

追記

2015/06/23 06:57

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
-
9
+ **item model**
10
10
 
11
11
  ```lang-<ruby>
12
12