From 5e0b771412174d55a39c6ad1fb442c6e4f156f27 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 12 Apr 2019 10:57:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 12 +++++++++--- app/views/users/_l_course.html.erb | 2 +- app/views/users/_l_project.html.erb | 1 + app/views/users/_l_shixun.html.erb | 1 + app/views/users/_p_path.html.erb | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index af38d85d..5a160436 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2559,10 +2559,16 @@ class UsersController < ApplicationController end end @objects_count = @objects.size - @new_icon = @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) - # 用户进自己主页的全部列表时有个新建入口,所以翻页只有15个 - @objects = paginateHelper @objects, 15 + # 用户访问自己主页的"我管理的"列表,且是第一页才显示新建入口 + page = params[:page] ? params[:page].to_i : 1 + @new_icon = @user == User.current && ['a_course', 'a_shixun', 'a_project', 'a_path'].include?(@type) && page == 1 + + # 用户进自己主页的全部列表时有个新建入口,加一个"new",view层的第一页需要shift,这样翻页就没问题啦 + @objects = @objects.to_a + @objects.unshift("new") if @new_icon + + @objects = paginateHelper @objects, 16 respond_to do |format| format.js diff --git a/app/views/users/_l_course.html.erb b/app/views/users/_l_course.html.erb index 195fc2d9..f7164017 100644 --- a/app/views/users/_l_course.html.erb +++ b/app/views/users/_l_course.html.erb @@ -40,7 +40,7 @@ - + <% @objects.shift %> <% end %> diff --git a/app/views/users/_l_project.html.erb b/app/views/users/_l_project.html.erb index 83ee900e..0113c646 100644 --- a/app/views/users/_l_project.html.erb +++ b/app/views/users/_l_project.html.erb @@ -42,6 +42,7 @@ + <% @objects.shift %> <% end %> <% @objects.each do |object| %> diff --git a/app/views/users/_l_shixun.html.erb b/app/views/users/_l_shixun.html.erb index 49c9e78a..68dcdf6c 100644 --- a/app/views/users/_l_shixun.html.erb +++ b/app/views/users/_l_shixun.html.erb @@ -61,6 +61,7 @@ + <% @objects.shift %> <% end %> <% @objects.each do |object| %> diff --git a/app/views/users/_p_path.html.erb b/app/views/users/_p_path.html.erb index 408c094f..96fe683b 100644 --- a/app/views/users/_p_path.html.erb +++ b/app/views/users/_p_path.html.erb @@ -49,6 +49,7 @@ + <% @objects.shift %> <% end %>