2024-10-31 23:13:18 +01:00
|
|
|
class Page < ApplicationRecord
|
2024-11-01 03:59:49 +01:00
|
|
|
belongs_to :report, touch: true
|
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
|