From b7578443ae64ff276207ff978c5d168fb5c9b68d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 30 Sep 2019 10:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E6=B5=81=E9=97=AE=E7=AD=94=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8Atab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 4 ++-- app/helpers/memos_helper.rb | 2 +- app/models/forum.rb | 1 + db/migrate/20190930020534_migrate_forum_name.rb | 9 +++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190930020534_migrate_forum_name.rb diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 88139fe7e..d2c386681 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -25,9 +25,9 @@ class MemosController < ApplicationController !search.blank? ? "forum_id = #{forum_id} and root_id is null and subject like '%#{search}%'" : "forum_id = #{forum_id} and root_id is null" elsif !search.blank? - "forum_id in(3, 5) and root_id is null and subject like '%#{search}%'" + "forum_id in(3, 5, 16) and root_id is null and subject like '%#{search}%'" else - "forum_id in(3, 5) and root_id is null" + "forum_id in(3, 5, 16) and root_id is null" end if tag_repertoire_id diff --git a/app/helpers/memos_helper.rb b/app/helpers/memos_helper.rb index 434d9b66a..ea84ec2c1 100644 --- a/app/helpers/memos_helper.rb +++ b/app/helpers/memos_helper.rb @@ -1,6 +1,6 @@ module MemosHelper def forum_list - [{id: 5, name: "技术分享"}, {id: 3, name: "操作指南"}] + [{id: 5, name: "技术分享"}, {id: 3, name: "操作指南"}, {id: 16, name: "通知公告"}] end end diff --git a/app/models/forum.rb b/app/models/forum.rb index 88aafa676..cd9b76a96 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,2 +1,3 @@ class Forum < ApplicationRecord + has_many :memos, dependent: :destroy end diff --git a/db/migrate/20190930020534_migrate_forum_name.rb b/db/migrate/20190930020534_migrate_forum_name.rb new file mode 100644 index 000000000..102d8c9a0 --- /dev/null +++ b/db/migrate/20190930020534_migrate_forum_name.rb @@ -0,0 +1,9 @@ +class MigrateForumName < ActiveRecord::Migration[5.2] + def change + forum = Forum.find_by(id: 16) + if forum.present? + forum.update_attributes(name: "通知公告") + forum.memos.destroy_all + end + end +end