pagination helpers: convert to strong params.

This commit is contained in:
evazion
2018-02-03 16:37:38 -06:00
parent 27f2b9d365
commit 583520b97c
2 changed files with 19 additions and 11 deletions

View File

@@ -5,17 +5,13 @@ module PostsHelper
def next_page_url
current_page = (params[:page] || 1).to_i
dup_params = params.dup
dup_params[:page] = current_page + 1
url_for(dup_params).html_safe
url_for(nav_params.merge(page: current_page + 1)).html_safe
end
def prev_page_url
current_page = (params[:page] || 1).to_i
if current_page >= 2
dup_params = params.dup
dup_params[:page] = current_page - 1
url_for(dup_params).html_safe
url_for(nav_params.merge(page: current_page - 1)).html_safe
else
nil
end
@@ -135,4 +131,10 @@ module PostsHelper
html.html_safe
end
private
def nav_params
params.to_unsafe_h # XXX
end
end