forked from fixin.me/fixin.me
Cached attribute definition (attr_cached)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class Quantity < ApplicationRecord
|
||||
ATTRIBUTES = [:name, :description, :parent_id]
|
||||
attr_cached :depth, :pathname
|
||||
|
||||
belongs_to :user, optional: true
|
||||
belongs_to :parent, optional: true, class_name: "Quantity"
|
||||
@@ -70,10 +71,6 @@ class Quantity < ApplicationRecord
|
||||
self[:depth] = parent&.depth&.succ || 0
|
||||
end
|
||||
|
||||
def depth=(value)
|
||||
raise ActiveRecord::ReadonlyAttributeError
|
||||
end
|
||||
|
||||
scope :defaults, ->{ where(user: nil) }
|
||||
|
||||
# Return: ordered [sub]hierarchy
|
||||
|
||||
Reference in New Issue
Block a user