diff --git a/app/models/subject.rb b/app/models/subject.rb index 70f9700df..387e5adb1 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -41,6 +41,7 @@ class Subject < ApplicationRecord scope :published, lambda{where(status: 1)} scope :unhidden, lambda{where(hidden: 0)} scope :publiced, lambda{ where(public: 2) } + scope :show_moblied, lambda{ where(show_mobile: true) } after_create :send_tiding def send_tiding diff --git a/app/queries/weapps/subject_query.rb b/app/queries/weapps/subject_query.rb index 8bfe9e9a8..e2f5625e1 100644 --- a/app/queries/weapps/subject_query.rb +++ b/app/queries/weapps/subject_query.rb @@ -8,7 +8,7 @@ class Weapps::SubjectQuery < ApplicationQuery end def call - subjects = @current_laboratory.subjects.unhidden.publiced + subjects = @current_laboratory.subjects.unhidden.publiced.show_moblied # 课程体系的过滤 if params[:sub_discipline_id].present? diff --git a/db/migrate/20200223021427_sync_subjectds_mobile.rb b/db/migrate/20200223021427_sync_subjectds_mobile.rb index 72b4ee18e..683821ff9 100644 --- a/db/migrate/20200223021427_sync_subjectds_mobile.rb +++ b/db/migrate/20200223021427_sync_subjectds_mobile.rb @@ -1,7 +1,8 @@ class SyncSubjectdsMobile < ActiveRecord::Migration[5.2] def change - SubDisciplineContainer.where(container_type: "Subject").find_each do |sc| - Subject.find(sc.container_id).update_column("show_mobile", true) + + SubDisciplineContainer.find_each do |sc| + Subject.find(sc.container_id).update_column(:show_mobile, true) end end end