This commit is contained in:
2025-11-07 13:34:32 -08:00
commit 1e8c5a972b
436 changed files with 11000 additions and 0 deletions

18
app/models/edit.rb Normal file
View File

@@ -0,0 +1,18 @@
class Edit < ApplicationRecord
belongs_to :leaf
delegated_type :leafable, types: Leafable::TYPES, dependent: :destroy
enum :action, %w[ revision trash ].index_by(&:itself)
scope :sorted, -> { order(created_at: :desc) }
scope :before, ->(edit) { where("created_at < ?", edit.created_at) }
scope :after, ->(edit) { where("created_at > ?", edit.created_at) }
def previous
leaf.edits.before(self).last
end
def next
leaf.edits.after(self).first
end
end