Wiki のバージョン管理 (#317) (#333)

#317

#317

#317

#317

#317

#317

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #333
This commit was merged in pull request #333.
This commit is contained in:
2026-04-26 22:17:25 +09:00
parent b2c3e02ccc
commit 0ff7fdf78a
23 changed files with 1648 additions and 155 deletions
+2 -1
View File
@@ -2,5 +2,6 @@ class IpAddress < ApplicationRecord
validates :ip_address, presence: true, length: { maximum: 16 }
validates :banned, inclusion: { in: [true, false] }
has_many :users
has_many :user_ips, dependent: :destroy
has_many :users, through: :user_ips
end
+3 -5
View File
@@ -13,8 +13,11 @@ class WikiPage < ApplicationRecord
foreign_key: :redirect_page_id,
dependent: :nullify
has_many :wiki_versions
belongs_to :tag_name
validates :tag_name, presence: true
validates :body, presence: true
def title = tag_name.name
@@ -24,11 +27,6 @@ class WikiPage < ApplicationRecord
def current_revision = wiki_revisions.order(id: :desc).first
def body
rev = current_revision
rev.body if rev&.content?
end
def resolve_redirect limit: 10
page = self
visited = Set.new
+8
View File
@@ -0,0 +1,8 @@
class WikiVersion < ApplicationRecord
include VersionRecord
belongs_to :wiki_page
validates :title, presence: true
validates :body, presence: true
end