forked from fixin.me/fixin.me
Cleanup
This commit is contained in:
parent
2fdd770457
commit
6300273186
@ -47,7 +47,6 @@ class QuantitiesController < ApplicationController
|
|||||||
render_no_content(@quantity) unless @quantity.update(permitted)
|
render_no_content(@quantity) unless @quantity.update(permitted)
|
||||||
|
|
||||||
@ancestors = @quantity.ancestors
|
@ancestors = @quantity.ancestors
|
||||||
@quantity.depth = @ancestors.length
|
|
||||||
@self_and_progenies = @quantity.with_progenies
|
@self_and_progenies = @quantity.with_progenies
|
||||||
@before = @self_and_progenies.last.successive
|
@before = @self_and_progenies.last.successive
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ class Quantity < ApplicationRecord
|
|||||||
numbered.project(
|
numbered.project(
|
||||||
numbered[Arel.star],
|
numbered[Arel.star],
|
||||||
numbered.cast(numbered[:child_number], 'BINARY').as('path'),
|
numbered.cast(numbered[:child_number], 'BINARY').as('path'),
|
||||||
).where(root ? numbered[:id].eq(root.id) : numbered[:parent_id].eq(nil)),
|
).where(numbered[root ? :id : :parent_id].eq(root)),
|
||||||
numbered.project(
|
numbered.project(
|
||||||
numbered[Arel.star],
|
numbered[Arel.star],
|
||||||
arel_table[:path].concat(numbered[:child_number]),
|
arel_table[:path].concat(numbered[:child_number]),
|
||||||
@ -121,7 +121,7 @@ class Quantity < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_progenies
|
def with_progenies
|
||||||
user.quantities.ordered(root: self).to_a
|
user.quantities.ordered(root: id).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return: record with ID `of` with its ancestors, sorted by `depth`
|
# Return: record with ID `of` with its ancestors, sorted by `depth`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user