This commit is contained in:
2026-05-10 05:03:27 +09:00
parent de86879e79
commit 5b50642756
12 changed files with 185 additions and 122 deletions
+2
View File
@@ -28,6 +28,8 @@ class Post < ApplicationRecord
has_one_attached :thumbnail
attribute :version_no, :integer, default: 1
before_validation :normalise_url
validates :url, presence: true, uniqueness: true
+2 -1
View File
@@ -40,6 +40,8 @@ class Tag < ApplicationRecord
belongs_to :tag_name
delegate :wiki_page, to: :tag_name
attribute :version_no, :integer, default: 1
delegate :name, to: :tag_name, allow_nil: true
validates :tag_name, presence: true
@@ -136,7 +138,6 @@ class Tag < ApplicationRecord
tn = tn.canonical if tn.canonical_id?
Tag.find_undiscard_or_create_by!(tag_name_id: tn.id) do |t|
t.version_no = TagVersion.where(tag_id: t.id).order(version_no: :desc).first || 1
t.category = category
end
rescue ActiveRecord::RecordNotUnique
+2
View File
@@ -15,6 +15,8 @@ class WikiPage < ApplicationRecord
has_many :wiki_versions
attribute :version_no, :integer, default: 1
belongs_to :tag_name
validates :tag_name, presence: true
validates :body, presence: true