From 208ac3cac305274c678d14efc2581665110db658 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sun, 23 Feb 2020 11:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=8F=8A=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/subject_settings_controller.rb | 6 ------ db/migrate/20200223021427_sync_subjectds_mobile.rb | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20200223021427_sync_subjectds_mobile.rb diff --git a/app/controllers/admins/subject_settings_controller.rb b/app/controllers/admins/subject_settings_controller.rb index 10a3139e4..8fa9fde8a 100644 --- a/app/controllers/admins/subject_settings_controller.rb +++ b/app/controllers/admins/subject_settings_controller.rb @@ -8,12 +8,6 @@ class Admins::SubjectSettingsController < Admins::BaseController end def update - # 为了复用代码 - if params["show_moblie"] - subject.find(params[:id]).update_attributes(:show_moblie => params[:show_moblie]) - return - end - sub_discipline_ids = params[:sub_disciplines] || [] sub_ids = sub_discipline_ids.reject(&:blank?).map(&:to_i) old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id) diff --git a/db/migrate/20200223021427_sync_subjectds_mobile.rb b/db/migrate/20200223021427_sync_subjectds_mobile.rb new file mode 100644 index 000000000..1c2fb6c3e --- /dev/null +++ b/db/migrate/20200223021427_sync_subjectds_mobile.rb @@ -0,0 +1,7 @@ +class SyncSubjectdsMobile < ActiveRecord::Migration[5.2] + def change + SubDisciplineContainer.find_each do |sc| + subject.find(sc.container_id).update_column(:show_mobile => true) + end + end +end