dev_forum
cxt 5 years ago
parent c44398672a
commit 603d6a4aec

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

@ -323,12 +323,7 @@ class User < ApplicationRecord
elsif business?
Course::BUSINESS
else
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
role = course.course_members.find_by(user_id: id, is_active: 1)&.role
case role
when nil then Course::NORMAL
when 'CREATOR' then Course::CREATOR

Loading…
Cancel
Save