云上实验室

dev_forge
cxt 5 years ago
parent 905715a7a7
commit 11175a3355

@ -20,8 +20,8 @@ class HomeController < ApplicationController
shixuns = shixuns.where(homepage_show: true)
subjects = subjects.where(homepage_show: true)
else
shixuns = shixuns.where(laboratory_shixuns: { homepage: true })
subjects = subjects.where(laboratory_subjects: { homepage: true })
shixuns = shixuns.joins(:laboratory_shixuns).where(laboratory_shixuns: { homepage: true })
subjects = subjects.joins(:laboratory_subjects).where(laboratory_subjects: { homepage: true })
end
@shixuns = shixuns.includes(:tag_repertoires, :challenges).limit(8)

@ -53,7 +53,7 @@ class Laboratory < ApplicationRecord
laboratory_shixun_ids = laboratory_shixuns.pluck(:shixun_id)
school_shixun_ids = Shixun.joins("join user_extensions on shixuns.user_id=user_extensions.user_id").where(user_extensions: { school_id: school_id }).pluck(:id)
shixun_ids = laboratory_shixun_ids + school_shixun_ids
Shixun.joins(:laboratory_shixuns).where(id: shixun_ids.uniq)
Shixun.where(id: shixun_ids.uniq)
else
Shixun.joins(:laboratory_shixuns).where(laboratory_shixuns: { laboratory_id: id })
end
@ -66,7 +66,7 @@ class Laboratory < ApplicationRecord
laboratory_subject_ids = laboratory_subjects.pluck(:subject_id)
school_subject_ids = Subject.joins("join user_extensions on subjects.user_id=user_extensions.user_id").where(user_extensions: { school_id: school_id }).pluck(:id)
subject_ids = laboratory_subject_ids + school_subject_ids
Subject.joins(:laboratory_subjects).where(id: subject_ids.uniq)
Subject.where(id: subject_ids.uniq)
else
Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id })
end

Loading…
Cancel
Save