dev_forum
cxt 5 years ago
parent c44398672a
commit 603d6a4aec

@ -96,7 +96,7 @@ class CoursesController < ApplicationController
limit = params[:limit] || 16 limit = params[:limit] || 16
@courses = @courses.page(page).per(limit) @courses = @courses.page(page).per(limit)
@courses = @courses.preload(:school, :course_members, teacher: :user_extension) @courses = @courses.preload(:school, teacher: :user_extension)
end end
def visits_plus_one def visits_plus_one

@ -323,12 +323,7 @@ class User < ApplicationRecord
elsif business? elsif business?
Course::BUSINESS Course::BUSINESS
else else
role = role = course.course_members.find_by(user_id: id, is_active: 1)&.role
if course.course_members.loaded?
course.course_members.find{|member| member.user_id == id && member.is_active == 1}&.role
else
course.course_members.find_by(user_id: id, is_active: 1)&.role
end
case role case role
when nil then Course::NORMAL when nil then Course::NORMAL
when 'CREATOR' then Course::CREATOR when 'CREATOR' then Course::CREATOR

Loading…
Cancel
Save