Update Measurements#new form pathnames on actions

This commit is contained in:
2025-05-07 00:24:05 +02:00
parent 9dbcfddf98
commit ef3484dfdf
11 changed files with 61 additions and 37 deletions

View File

@@ -144,7 +144,7 @@ class Quantity < ApplicationRecord
user.quantities.ordered(root: id, include_root: false).to_a
end
# Return: record with ID `of` with its ancestors, sorted by `depth`
# Return: record with ID `of` with its ancestors, sorted by :depth
scope :with_ancestors, ->(of) {
selected = Arel::Table.new('selected')
@@ -163,4 +163,8 @@ class Quantity < ApplicationRecord
def ancestor_of?(progeny)
user.quantities.with_ancestors(progeny.id).exists?(id)
end
def relative_pathname(ancestor)
pathname.delete_prefix(ancestor&.pathname || '')
end
end