1
- class Tag < ActiveRecord ::Base
2
- has_closure_tree :dependent => :destroy , :order => :name
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord ::Base
4
+ self . abstract_class = true
5
+ end
6
+
7
+ class Tag < ApplicationRecord
8
+ has_closure_tree dependent : :destroy , order : :name
3
9
before_destroy :add_destroyed_tag
4
10
5
11
def to_s
@@ -8,11 +14,11 @@ def to_s
8
14
9
15
def add_destroyed_tag
10
16
# Proof for the tests that the destroy rather than the delete method was called:
11
- DestroyedTag . create ( : name => name )
17
+ DestroyedTag . create ( name : )
12
18
end
13
19
end
14
20
15
- class UUIDTag < ActiveRecord :: Base
21
+ class UUIDTag < ApplicationRecord
16
22
self . primary_key = :uuid
17
23
before_create :set_uuid
18
24
has_closure_tree dependent : :destroy , order : 'name' , parent_column_name : 'parent_uuid'
@@ -28,62 +34,62 @@ def to_s
28
34
29
35
def add_destroyed_tag
30
36
# Proof for the tests that the destroy rather than the delete method was called:
31
- DestroyedTag . create ( : name => name )
37
+ DestroyedTag . create ( name : )
32
38
end
33
39
end
34
40
35
- class DestroyedTag < ActiveRecord :: Base
41
+ class DestroyedTag < ApplicationRecord
36
42
end
37
43
38
- class Group < ActiveRecord :: Base
44
+ class Group < ApplicationRecord
39
45
has_closure_tree_root :root_user
40
46
end
41
47
42
- class Grouping < ActiveRecord :: Base
43
- has_closure_tree_root :root_person , class_name : " User" , foreign_key : :group_id
48
+ class Grouping < ApplicationRecord
49
+ has_closure_tree_root :root_person , class_name : ' User' , foreign_key : :group_id
44
50
end
45
51
46
- class UserSet < ActiveRecord :: Base
47
- has_closure_tree_root :root_user , class_name : " Useur"
52
+ class UserSet < ApplicationRecord
53
+ has_closure_tree_root :root_user , class_name : ' Useur'
48
54
end
49
55
50
- class Team < ActiveRecord :: Base
51
- has_closure_tree_root :root_user , class_name : " User" , foreign_key : :grp_id
56
+ class Team < ApplicationRecord
57
+ has_closure_tree_root :root_user , class_name : ' User' , foreign_key : :grp_id
52
58
end
53
59
54
- class User < ActiveRecord :: Base
55
- acts_as_tree : parent_column_name => " referrer_id" ,
56
- :name_column => 'email' ,
57
- :hierarchy_class_name => 'ReferralHierarchy' ,
58
- :hierarchy_table_name => 'referral_hierarchies'
60
+ class User < ApplicationRecord
61
+ acts_as_tree parent_column_name : ' referrer_id' ,
62
+ name_column : 'email' ,
63
+ hierarchy_class_name : 'ReferralHierarchy' ,
64
+ hierarchy_table_name : 'referral_hierarchies'
59
65
60
66
has_many :contracts , inverse_of : :user
61
67
belongs_to :group # Can't use and don't need inverse_of here when using has_closure_tree_root.
62
68
63
69
def indirect_contracts
64
- Contract . where ( : user_id => descendant_ids )
70
+ Contract . where ( user_id : descendant_ids )
65
71
end
66
72
67
73
def to_s
68
74
email
69
75
end
70
76
end
71
77
72
- class Contract < ActiveRecord :: Base
78
+ class Contract < ApplicationRecord
73
79
belongs_to :user , inverse_of : :contracts
74
80
belongs_to :contract_type , inverse_of : :contracts
75
81
end
76
82
77
- class ContractType < ActiveRecord :: Base
83
+ class ContractType < ApplicationRecord
78
84
has_many :contracts , inverse_of : :contract_type
79
85
end
80
86
81
- class Label < ActiveRecord :: Base
87
+ class Label < ApplicationRecord
82
88
# make sure order doesn't matter
83
- acts_as_tree : order => :column_whereby_ordering_is_inferred , # <- symbol, and not "sort_order"
84
- :numeric_order => true ,
85
- :parent_column_name => " mother_id" ,
86
- :dependent => :destroy
89
+ acts_as_tree order : :column_whereby_ordering_is_inferred , # <- symbol, and not "sort_order"
90
+ numeric_order : true ,
91
+ parent_column_name : ' mother_id' ,
92
+ dependent : :destroy
87
93
88
94
def to_s
89
95
"#{ self . class } : #{ name } "
@@ -99,13 +105,13 @@ class DateLabel < Label
99
105
class DirectoryLabel < Label
100
106
end
101
107
102
- class LabelWithoutRootOrdering < ActiveRecord :: Base
108
+ class LabelWithoutRootOrdering < ApplicationRecord
103
109
# make sure order doesn't matter
104
- acts_as_tree : order => :column_whereby_ordering_is_inferred , # <- symbol, and not "sort_order"
105
- :numeric_order => true ,
106
- :dont_order_roots => true ,
107
- :parent_column_name => " mother_id" ,
108
- :hierarchy_table_name => " label_hierarchies"
110
+ acts_as_tree order : :column_whereby_ordering_is_inferred , # <- symbol, and not "sort_order"
111
+ numeric_order : true ,
112
+ dont_order_roots : true ,
113
+ parent_column_name : ' mother_id' ,
114
+ hierarchy_table_name : ' label_hierarchies'
109
115
110
116
self . table_name = "#{ table_name_prefix } labels#{ table_name_suffix } "
111
117
@@ -114,20 +120,21 @@ def to_s
114
120
end
115
121
end
116
122
117
- class CuisineType < ActiveRecord :: Base
123
+ class CuisineType < ApplicationRecord
118
124
acts_as_tree
119
125
end
120
126
121
127
module Namespace
122
128
def self . table_name_prefix
123
129
'namespace_'
124
130
end
125
- class Type < ActiveRecord ::Base
131
+
132
+ class Type < ApplicationRecord
126
133
has_closure_tree dependent : :destroy
127
134
end
128
135
end
129
136
130
- class Metal < ActiveRecord :: Base
137
+ class Metal < ApplicationRecord
131
138
self . table_name = "#{ table_name_prefix } metal#{ table_name_suffix } "
132
139
has_closure_tree order : 'sort_order' , name_column : 'value'
133
140
self . inheritance_column = 'metal_type'
@@ -139,6 +146,6 @@ class Adamantium < Metal
139
146
class Unobtanium < Metal
140
147
end
141
148
142
- class MenuItem < ActiveRecord :: Base
149
+ class MenuItem < ApplicationRecord
143
150
has_closure_tree touch : true , with_advisory_lock : false
144
151
end
0 commit comments