forked from fixin.me/fixin.me
Partial refresh of Measurements#new form
This commit is contained in:
@@ -3,8 +3,8 @@ class Quantity < ApplicationRecord
|
||||
|
||||
belongs_to :user, optional: true
|
||||
belongs_to :parent, optional: true, class_name: "Quantity"
|
||||
has_many :subquantities, class_name: "Quantity", inverse_of: :parent,
|
||||
dependent: :restrict_with_error
|
||||
has_many :subquantities, ->{ order(:name) }, class_name: "Quantity",
|
||||
inverse_of: :parent, dependent: :restrict_with_error
|
||||
|
||||
validate if: ->{ parent.present? } do
|
||||
errors.add(:parent, :user_mismatch) unless user_id == parent.user_id
|
||||
@@ -168,8 +168,10 @@ class Quantity < ApplicationRecord
|
||||
user.quantities.with_ancestors(progeny.id).exists?(id)
|
||||
end
|
||||
|
||||
def fullname
|
||||
def self.full_names!(of)
|
||||
self['fullname'] ||
|
||||
user.quantities.with_ancestors(id).order(:depth).map(&:name).join(' → ')
|
||||
end
|
||||
scope :with_full_name, ->{
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user