Skip to content

Commit 07faddc

Browse files

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/serializers/category_serializer.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ class CategorySerializer < ActiveModel::Serializer
33
has_one :user
44
has_many :posts
55
def posts
6-
post_page = instance_options.dig(:pagaination_param, :post_page).presence.to_i || 1
7-
post_per = instance_options.dig(:pagaination_param, :post_per).presence.to_i || 10
6+
post_page = (instance_options.dig(:pagaination_param, :post_page).presence || 1).to_i
7+
post_per = (instance_options.dig(:pagaination_param, :post_per).presence || 0).to_i
88
object.posts.published.by_date.page(post_page).per(post_per)
99
end
1010
def posts_pagination
11-
post_per = instance_options.dig(:pagaination_param, :post_per).presence.to_i || 10
11+
post_per = (instance_options.dig(:pagaination_param, :post_per).presence || 10).to_i
1212
Pagination.build_json(posts)[:posts_pagination] if post_per > 0
1313
end
1414
end

app/serializers/post_serializer.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ def files
1111
file_urls
1212
end
1313
def comments
14-
comment_page = instance_options.dig(:pagaination_param, :comment_page).presence.to_i || 1
15-
comment_per = instance_options.dig(:pagaination_param, :comment_per).presence.to_i || 0
14+
comment_page = (instance_options.dig(:pagaination_param, :comment_page).presence || 1).to_i
15+
comment_per = (instance_options.dig(:pagaination_param, :comment_per).presence || 10).to_i
1616
object.comments.published.by_date.page(comment_page).per(comment_per)
1717
end
1818
def comments_pagination
19-
comment_per = instance_options.dig(:pagaination_param, :comment_per).presence.to_i || 0
19+
comment_per = (instance_options.dig(:pagaination_param, :comment_per).presence || 10).to_i
2020
Pagination.build_json(comments)[:comments_pagination] if comment_per > 0
2121
end
2222
end

0 commit comments

Comments
 (0)