个人主页,TA的课程显示和课程数量、课程列表不匹配
This commit is contained in:
parent
6775008b50
commit
ce17cb1da0
|
@ -448,7 +448,7 @@ class UsersController < ApplicationController
|
|||
|
||||
def user_courses4show
|
||||
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
||||
query = query.where("m.user_id = ?",@user.id)
|
||||
query = query.where("m.user_id = ?",@user.id).order("#{Course.table_name}.id desc")
|
||||
if User.current == @user #看自己
|
||||
else
|
||||
if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
|
||||
|
@ -456,13 +456,12 @@ class UsersController < ApplicationController
|
|||
query = query.where("r.role_id in(3,7,9)")
|
||||
end
|
||||
query = query.where(Course.table_name+".is_public = 1")
|
||||
# or exists (select 1 from courses c2,members m2 where c2.id=m2.course_id and c2.id=#{Course.table_name}.id and m2.user_id= User.current.id)
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("( (#{Course.table_name}.updated_at=? and #{Course.table_name}.id < ?) or #{Course.table_name}.updated_at<?)",params[:lasttime],params[:lastid],params[:lasttime])
|
||||
query = query.where(" #{Course.table_name}.id < ?",params[:lastid],)
|
||||
end
|
||||
@list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(8).all
|
||||
@list = query.limit(8)
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue