This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user