質問編集履歴
1
payment_helperの記載追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -183,4 +183,27 @@
|
|
183
183
|
</div>
|
184
184
|
</div>
|
185
185
|
</div>
|
186
|
+
```
|
187
|
+
|
188
|
+
payments_helper.rb
|
189
|
+
```
|
190
|
+
module PaymentsHelper
|
191
|
+
|
192
|
+
def this_month
|
193
|
+
Date.today
|
194
|
+
end
|
195
|
+
|
196
|
+
def payments_this_month
|
197
|
+
@payments_this_month = current_user.payments.where(created_at: this_month.in_time_zone.all_month)
|
198
|
+
end
|
199
|
+
|
200
|
+
def sum_payment_this_month
|
201
|
+
sum = 0
|
202
|
+
payments_this_month
|
203
|
+
@payments_this_month.each { |n| sum += n.price}
|
204
|
+
sum
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
end
|
186
209
|
```
|