diff --git a/app/models/forum_section.rb b/app/models/forum_section.rb new file mode 100644 index 000000000..a6bab765f --- /dev/null +++ b/app/models/forum_section.rb @@ -0,0 +1,4 @@ +class ForumSection < ApplicationRecord + has_many :memos, dependent: :destroy + +end \ No newline at end of file diff --git a/app/models/memo.rb b/app/models/memo.rb index bb71e9014..a3acdb73a 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -45,6 +45,7 @@ class Memo < ApplicationRecord include Watchable belongs_to :author, :class_name => "User", foreign_key: :author_id, counter_cache: true + belongs_to :forum_section, counter_cache: true enum destroy_status: {common: 0, apply_destroy: 1} diff --git a/app/views/api/v1/users/memos/_memo.json.jbuilder b/app/views/api/v1/users/memos/_memo.json.jbuilder index 11584d0ff..0154319a6 100644 --- a/app/views/api/v1/users/memos/_memo.json.jbuilder +++ b/app/views/api/v1/users/memos/_memo.json.jbuilder @@ -3,7 +3,7 @@ json.apply_destroy memo.apply_destroy? json.content memo.content json.cover_url memo.cover_url json.forum_section_id memo.forum_section_id -json.forum_section_title memo.forum_section_title +json.forum_section_title memo.forum_section&.title json.id memo.id json.is_fine memo.is_fine json.is_original memo.is_original