Skip to content

Commit

Permalink
add pagy for likes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlazypanda committed Sep 30, 2020
1 parent 1a61864 commit 698aca0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/like_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LikeController < ApplicationController
# list all recent likes
def index
@paginated = true
@likes = NodeSelection.all.reverse.paginate(page: params[:page])
@pagy_a, @likes = pagy_array(NodeSelection.all.reverse)
end

# return a count of likes for a given node
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ def profile
def likes
@user = User.find_by(username: params[:id])
@title = "Liked by " + @user.name
@notes = @user.liked_notes
.includes(%i(tag comments))
.paginate(page: params[:page], per_page: 24)
@pagy, @notes = pagy(@user.liked_notes
.includes(%i(tag comments)), items:24)
@wikis = @user.liked_pages
@tagnames = []
@unpaginated = false
Expand Down
8 changes: 5 additions & 3 deletions app/views/like/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
</tr>
<% end %>
</table>

<%= will_paginate @likes, renderer: WillPaginate::ActionView::BootstrapLinkRenderer if @paginated %>

<% if @pagy_a %>
<%= raw pagy_bootstrap_nav @pagy_a if @paginated %>
<% else %>
<%= will_paginate @likes, renderer: WillPaginate::ActionView::BootstrapLinkRenderer if @paginated %>
<% end %>
</div>

<%= render :partial => "sidebar/featured" %>
1 change: 1 addition & 0 deletions config/initializers/pagy.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require 'pagy/extras/bootstrap'
require 'pagy/extras/array'

0 comments on commit 698aca0

Please sign in to comment.