質問編集履歴
2
コードの記述を修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,17 +7,17 @@
|
|
7
7
|
|
8
8
|
# 今月の月初めと月末までの投稿数を取得
|
9
9
|
this_month = Time.now.at_beginning_of_month
|
10
|
-
to_this_month = this_month + 1.month
|
10
|
+
to_this_month = this_month + 1.month
|
11
11
|
@this_month = Post.where(user_id: @user.id, created_at: this_month...to_this_month).count
|
12
12
|
|
13
13
|
# 先月の投稿数
|
14
14
|
last_month = this_month.last_month
|
15
|
-
to_last_month = last_month + 1.month
|
15
|
+
to_last_month = last_month + 1.month
|
16
16
|
@last_month = Post.where(user_id: @user.id, created_at: last_month...to_last_month).count
|
17
17
|
|
18
18
|
# 先々月の投稿数
|
19
19
|
month_before_last = this_month.month_ago(2)
|
20
|
-
to_month_before_last = month_before_last + 1.month
|
20
|
+
to_month_before_last = month_before_last + 1.month
|
21
21
|
@last_month = Post.where(user_id: @user.id, created_at: last_month...to_last_month).count
|
22
22
|
```
|
23
23
|
|
1
文字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,17 +8,17 @@
|
|
8
8
|
# 今月の月初めと月末までの投稿数を取得
|
9
9
|
this_month = Time.now.at_beginning_of_month
|
10
10
|
to_this_month = this_month + 1.month - 1.day
|
11
|
-
@this_month = Post.where(user_id: @user.id,
|
11
|
+
@this_month = Post.where(user_id: @user.id, created_at: this_month...to_this_month).count
|
12
12
|
|
13
13
|
# 先月の投稿数
|
14
14
|
last_month = this_month.last_month
|
15
15
|
to_last_month = last_month + 1.month - 1.day
|
16
|
-
@last_month = Post.where(user_id: @user.id,
|
16
|
+
@last_month = Post.where(user_id: @user.id, created_at: last_month...to_last_month).count
|
17
17
|
|
18
18
|
# 先々月の投稿数
|
19
19
|
month_before_last = this_month.month_ago(2)
|
20
20
|
to_month_before_last = month_before_last + 1.month - 1.day
|
21
|
-
@last_month = Post.where(user_id: @user.id,
|
21
|
+
@last_month = Post.where(user_id: @user.id, created_at: last_month...to_last_month).count
|
22
22
|
```
|
23
23
|
|
24
24
|
もっとすっきりかけると思うのですが、いい案が思いつかず、お力を貸していただきたいです
|