回答編集履歴

1

コードの改善

2017/07/08 04:36

投稿

hns
hns

スコア10

test CHANGED
@@ -37,3 +37,43 @@
37
37
  ```
38
38
 
39
39
  これで一応動きます、一応
40
+
41
+
42
+
43
+
44
+
45
+ 一応updateしときます 2017/07/08
46
+
47
+
48
+
49
+ こうですね。
50
+
51
+
52
+
53
+ ```
54
+
55
+ before_create :response_confirmed_true
56
+
57
+ before_destroy :response_confirmed_false
58
+
59
+
60
+
61
+ private
62
+
63
+
64
+
65
+ def response_confirmed_true
66
+
67
+ self.thumbable.update_column(:any_responsed, true)
68
+
69
+ end
70
+
71
+
72
+
73
+ def response_confirmed_false
74
+
75
+ self.thumbable.update_column(:any_responsed, false) if self.thumbable.comments_count == 0
76
+
77
+ end
78
+
79
+ ```