ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

16 lines
417 B

  1. class WikiLine < ApplicationRecord
  2. has_many :wiki_revision_lines, dependent: :restrict_with_exception
  3. validates :sha256, presence: true, uniqueness: true, length: { is: 64 }
  4. validates :body, presence: true
  5. def self.upsert_by_body! body
  6. sha = Digest::SHA256.hexdigest(body)
  7. now = Time.current
  8. upsert({ sha256: sha, body:, created_at: now, updated_at: now })
  9. find_by!(sha256: sha)
  10. end
  11. end