From 67e900c1abcb9cd34ebd28f02a591fac1e1be2cd Mon Sep 17 00:00:00 2001 From: Sidharth Date: Sun, 11 Feb 2018 16:20:15 +0530 Subject: [PATCH] Profile page likes are now rendered on the same page --- 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 85f106d287..b605e141cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -117,6 +117,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 4a24f861d6..bf4c155834 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -174,7 +174,7 @@
  • -
  • (<%= @user.like_count %>)
  • +
  • (<%= @user.like_count %>)
  • (<%= @user.user.try(:barnstars).try(:length) %>)
  • @@ -222,6 +222,9 @@

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