From 133bca263c4bcf8bfb95f34ca20219953e1b0f0c Mon Sep 17 00:00:00 2001 From: Sidharth Bansal Date: Wed, 7 Mar 2018 21:18:44 +0530 Subject: [PATCH] Profile page likes are now rendered on the same page (#2293) --- app/controllers/users_controller.rb | 2 + app/views/users/_likes.html.erb | 69 +++++++++++++++++++++++++++++ app/views/users/profile.html.erb | 5 ++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 app/views/users/_likes.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 727ce09f34..eea801c63f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -118,6 +118,8 @@ def profile @questions = @user.user.questions .order('node.nid DESC') .paginate(:page => params[:page], :per_page => 24) + @likes = (@user.liked_notes.includes([:tag, :comments])+@user.liked_pages) + .paginate(page: params[:page], per_page: 24) questions = Node.questions .where(status: 1) .order('node.nid DESC') diff --git a/app/views/users/_likes.html.erb b/app/views/users/_likes.html.erb new file mode 100644 index 0000000000..7346572f08 --- /dev/null +++ b/app/views/users/_likes.html.erb @@ -0,0 +1,69 @@ +
+
+ <% @likes.each_with_index do |like,i| %> + + <% unless @widget %>
<% end %> + <% if ((i+1)/4.0).to_i == ((i+1)/4.0) %> +
+ <% unless @widget %>
<% end %> +
+ <% end %> + <% end %> +
+
+<%= will_paginate @likes, :renderer => BootstrapPagination::Rails unless @unpaginated %> diff --git a/app/views/users/profile.html.erb b/app/views/users/profile.html.erb index 568b0124e3..7785566364 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -176,7 +176,7 @@
  • (<%= @coauthored.size %>)
  • (<%= Node.questions.where(status: 1, uid: @user.id).length %>)
  • (<%= @comment_count %>)
  • -
  • (<%= @user.like_count %>)
  • +
  • (<%= @user.like_count %>)
  • (<%= @user.user.try(:barnstars).try(:length) %>)
  • @@ -224,6 +224,9 @@

    +
    + <%= render :partial => "users/likes" %> +
    <% if @user.user %> <% @user.user.barnstars.each do |tag| %>