fix moderation log pagination
This commit is contained in:
parent
aeb25d22b6
commit
0373bcdadb
|
@ -5,8 +5,12 @@ class ModerationsController < ApplicationController
|
|||
@pages = Moderation.count
|
||||
@page = params[:page] ? params[:page].to_i : 0
|
||||
|
||||
@pages = (Moderation.count / 50).ceil
|
||||
|
||||
if @page < 1
|
||||
@page = 1
|
||||
elsif @page < @pages
|
||||
@page = @pages
|
||||
end
|
||||
|
||||
@moderations = Moderation.order("id desc").limit(50).offset((@page - 1) *
|
||||
|
|
|
@ -38,17 +38,19 @@
|
|||
<% bit = (bit == 1 ? 0 : 1) %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<div class="morelink">
|
||||
<% if @page && @page > 1 %>
|
||||
<a href="/moderations/page/<%= @page - 1 %>"><< Page
|
||||
<%= @page - 1 %></a>
|
||||
<% end %>
|
||||
|
||||
<% if @page && @page > 1 %>
|
||||
|
|
||||
<a href="/moderations/page/<%= @page + 1 %>">Page <%= @page + 1
|
||||
%> >></a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="morelink">
|
||||
<% if @page > 1 %>
|
||||
<a href="/moderations/page/<%= @page - 1 %>"><< Page
|
||||
<%= @page - 1 %></a>
|
||||
<% end %>
|
||||
|
||||
<% if @pages > 1 && @page < @pages %>
|
||||
<% if @page > 1 %>
|
||||
|
|
||||
<% end %>
|
||||
<a href="/moderations/page/<%= @page + 1 %>">Page <%= @page + 1
|
||||
%> >></a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue