a11yist/app/models/page.rb

14 lines
262 B
Ruby
Raw Normal View History

2024-10-31 23:13:18 +01:00
class Page < ApplicationRecord
belongs_to :report
2024-11-01 00:50:15 +01:00
has_many :elements, dependent: :destroy
2024-10-31 23:13:18 +01:00
has_rich_text :comment
2024-11-01 03:26:46 +01:00
before_validation :set_position
private
def set_position
self.position ||= (report.pages.pluck(:position).max || 0) + 1
end
2024-10-31 23:13:18 +01:00
end