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