Class: Unidom::Category::CategoryRollup

Inherits:
ApplicationRecord show all
Includes:
Unidom::Common::Concerns::ModelExtension
Defined in:
app/models/unidom/category/category_rollup.rb

Overview

Category Rollup 是分类的层级关系。

Class Method Summary collapse

Class Method Details

.roll_up!(it, into: nil, at: Time.now) ⇒ Object



35
36
37
# File 'app/models/unidom/category/category_rollup.rb', line 35

def self.roll_up!(it, into: nil, at: Time.now)
  self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
end