搜索分页修改

This commit is contained in:
yuanke 2016-10-13 09:52:05 +08:00
parent 068a66ac35
commit 0265b6bfb7
1 changed files with 8 additions and 8 deletions

View File

@ -190,7 +190,7 @@ class WelcomeController < ApplicationController
case params[:search_type]
when 'all'
if (page-1)*20 > @total_count
if (page-1)*20 >= @total_count
page = 1
params[:page] = "1"
end
@ -220,42 +220,42 @@ class WelcomeController < ApplicationController
}
},[User,Syllabus,Course,Attachment,Project,Memo] ).page(page).per(20).results
when 'user'
if (page-1)*20 > @users_count
if (page-1)*20 >= @users_count
page = 1
params[:page] = "1"
end
@users = User.search(@name).page(page).per(20)
when 'syllabus'
if (page-1)*20 > @syllabus_count
if (page-1)*20 >= @syllabus_count
page = 1
params[:page] = "1"
end
@syllabuses = Syllabus.search(@name).page(page).per(20).results
when 'project'
if (page-1)*20 > @project_count
if (page-1)*20 >= @project_count
page = 1
end
@projects = Project.search(@name).page(page).per(20).results
when 'course'
if (page-1)*20 > @course_count
if (page-1)*20 >= @course_count
page = 1
params[:page] = "1"
end
@courses = Course.search(@name).page(page).per(20).results
when 'attachment'
if (page-1)*20 > @attach_count
if (page-1)*20 >= @attach_count
page = 1
params[:page] = "1"
end
@attachments = Attachment.search(@name).page(page).per(20).results
when 'memo'
if (page-1)*20 > @memo_count
if (page-1)*20 >= @memo_count
page = 1
params[:page] = "1"
end
@memos = Memo.search(@name).page(page).per(20).results
else
if (page-1)*20 > @total_count
if (page-1)*20 >= @total_count
page = 1
params[:page] = "1"
end