acts_as_paranoid 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +117 -0
- data/LICENSE +1 -1
- data/README.md +175 -50
- data/lib/acts_as_paranoid.rb +34 -31
- data/lib/acts_as_paranoid/associations.rb +28 -17
- data/lib/acts_as_paranoid/core.rb +144 -53
- data/lib/acts_as_paranoid/relation.rb +2 -0
- data/lib/acts_as_paranoid/validations.rb +8 -65
- data/lib/acts_as_paranoid/version.rb +3 -1
- data/test/test_associations.rb +161 -39
- data/test/test_core.rb +252 -55
- data/test/test_default_scopes.rb +38 -37
- data/test/test_helper.rb +136 -67
- data/test/test_inheritance.rb +5 -3
- data/test/test_relations.rb +29 -21
- data/test/test_validations.rb +10 -7
- metadata +80 -30
- data/lib/acts_as_paranoid/preloader_association.rb +0 -15
- data/test/test_preloader_association.rb +0 -27
data/test/test_default_scopes.rb
CHANGED
@@ -1,52 +1,53 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
2
4
|
|
3
5
|
class MultipleDefaultScopesTest < ParanoidBaseTest
|
4
6
|
def setup
|
5
7
|
setup_db
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ParanoidHuman.create! :gender => 'female'
|
9
|
+
ParanoidPolygon.create! sides: 3
|
10
|
+
ParanoidPolygon.create! sides: 3
|
11
|
+
ParanoidPolygon.create! sides: 3
|
12
|
+
ParanoidPolygon.create! sides: 8
|
12
13
|
|
13
|
-
assert_equal 3,
|
14
|
-
assert_equal 4,
|
14
|
+
assert_equal 3, ParanoidPolygon.count
|
15
|
+
assert_equal 4, ParanoidPolygon.unscoped.count
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_fake_removal_with_multiple_default_scope
|
18
|
-
|
19
|
-
assert_equal 2,
|
20
|
-
assert_equal 3,
|
21
|
-
assert_equal 1,
|
22
|
-
assert_equal 4,
|
23
|
-
|
24
|
-
|
25
|
-
assert_equal 0,
|
26
|
-
assert_equal 3,
|
27
|
-
assert_equal 3,
|
28
|
-
assert_equal 4,
|
19
|
+
ParanoidPolygon.first.destroy
|
20
|
+
assert_equal 2, ParanoidPolygon.count
|
21
|
+
assert_equal 3, ParanoidPolygon.with_deleted.count
|
22
|
+
assert_equal 1, ParanoidPolygon.only_deleted.count
|
23
|
+
assert_equal 4, ParanoidPolygon.unscoped.count
|
24
|
+
|
25
|
+
ParanoidPolygon.destroy_all
|
26
|
+
assert_equal 0, ParanoidPolygon.count
|
27
|
+
assert_equal 3, ParanoidPolygon.with_deleted.count
|
28
|
+
assert_equal 3, ParanoidPolygon.with_deleted.count
|
29
|
+
assert_equal 4, ParanoidPolygon.unscoped.count
|
29
30
|
end
|
30
31
|
|
31
32
|
def test_real_removal_with_multiple_default_scope
|
32
33
|
# two-step
|
33
|
-
|
34
|
-
|
35
|
-
assert_equal 2,
|
36
|
-
assert_equal 2,
|
37
|
-
assert_equal 0,
|
38
|
-
assert_equal 3,
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal 1,
|
42
|
-
assert_equal 1,
|
43
|
-
assert_equal 0,
|
44
|
-
assert_equal 2,
|
45
|
-
|
46
|
-
|
47
|
-
assert_equal 0,
|
48
|
-
assert_equal 0,
|
49
|
-
assert_equal 0,
|
50
|
-
assert_equal 1,
|
34
|
+
ParanoidPolygon.first.destroy
|
35
|
+
ParanoidPolygon.only_deleted.first.destroy
|
36
|
+
assert_equal 2, ParanoidPolygon.count
|
37
|
+
assert_equal 2, ParanoidPolygon.with_deleted.count
|
38
|
+
assert_equal 0, ParanoidPolygon.only_deleted.count
|
39
|
+
assert_equal 3, ParanoidPolygon.unscoped.count
|
40
|
+
|
41
|
+
ParanoidPolygon.first.destroy_fully!
|
42
|
+
assert_equal 1, ParanoidPolygon.count
|
43
|
+
assert_equal 1, ParanoidPolygon.with_deleted.count
|
44
|
+
assert_equal 0, ParanoidPolygon.only_deleted.count
|
45
|
+
assert_equal 2, ParanoidPolygon.unscoped.count
|
46
|
+
|
47
|
+
ParanoidPolygon.delete_all!
|
48
|
+
assert_equal 0, ParanoidPolygon.count
|
49
|
+
assert_equal 0, ParanoidPolygon.with_deleted.count
|
50
|
+
assert_equal 0, ParanoidPolygon.only_deleted.count
|
51
|
+
assert_equal 1, ParanoidPolygon.unscoped.count
|
51
52
|
end
|
52
53
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,23 +1,32 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler"
|
2
4
|
begin
|
3
|
-
Bundler.
|
5
|
+
Bundler.load
|
4
6
|
rescue Bundler::BundlerError => e
|
5
|
-
|
6
|
-
|
7
|
+
warn e.message
|
8
|
+
warn "Run `bundle install` to install missing gems"
|
7
9
|
exit e.status_code
|
8
10
|
end
|
9
11
|
|
10
|
-
require
|
11
|
-
|
12
|
+
require "simplecov"
|
13
|
+
SimpleCov.start do
|
14
|
+
enable_coverage :branch
|
15
|
+
end
|
16
|
+
|
17
|
+
require "acts_as_paranoid"
|
18
|
+
require "minitest/autorun"
|
12
19
|
|
13
20
|
# Silence deprecation halfway through the test
|
14
21
|
I18n.enforce_available_locales = true
|
15
22
|
|
16
|
-
ActiveRecord::Base.establish_connection(:
|
23
|
+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
17
24
|
ActiveRecord::Schema.verbose = false
|
18
25
|
|
26
|
+
# rubocop:disable Metrics/AbcSize
|
27
|
+
# rubocop:disable Metrics/MethodLength
|
19
28
|
def setup_db
|
20
|
-
ActiveRecord::Schema.define(:
|
29
|
+
ActiveRecord::Schema.define(version: 1) do # rubocop:disable Metrics/BlockLength
|
21
30
|
create_table :paranoid_times do |t|
|
22
31
|
t.string :name
|
23
32
|
t.datetime :deleted_at
|
@@ -31,7 +40,8 @@ def setup_db
|
|
31
40
|
t.string :name
|
32
41
|
t.boolean :is_deleted
|
33
42
|
t.integer :paranoid_time_id
|
34
|
-
|
43
|
+
t.integer :paranoid_with_counter_caches_count
|
44
|
+
t.integer :custom_counter_cache
|
35
45
|
timestamps t
|
36
46
|
end
|
37
47
|
|
@@ -111,14 +121,15 @@ def setup_db
|
|
111
121
|
|
112
122
|
create_table :super_paranoids do |t|
|
113
123
|
t.string :type
|
114
|
-
t.references :has_many_inherited_super_paranoidz,
|
124
|
+
t.references :has_many_inherited_super_paranoidz,
|
125
|
+
index: { name: "index__sp_id_on_has_many_isp" }
|
115
126
|
t.datetime :deleted_at
|
116
127
|
|
117
128
|
timestamps t
|
118
129
|
end
|
119
130
|
|
120
131
|
create_table :has_many_inherited_super_paranoidzs do |t|
|
121
|
-
t.references :super_paranoidz, index: { name:
|
132
|
+
t.references :super_paranoidz, index: { name: "index_has_many_isp_on_sp_id" }
|
122
133
|
t.datetime :deleted_at
|
123
134
|
|
124
135
|
timestamps t
|
@@ -148,7 +159,7 @@ def setup_db
|
|
148
159
|
timestamps t
|
149
160
|
end
|
150
161
|
|
151
|
-
|
162
|
+
create_table :paranoid_forests do |t|
|
152
163
|
t.string :name
|
153
164
|
t.boolean :rainforest
|
154
165
|
t.datetime :deleted_at
|
@@ -164,8 +175,8 @@ def setup_db
|
|
164
175
|
timestamps t
|
165
176
|
end
|
166
177
|
|
167
|
-
create_table :
|
168
|
-
t.
|
178
|
+
create_table :paranoid_polygons do |t|
|
179
|
+
t.integer :sides
|
169
180
|
t.datetime :deleted_at
|
170
181
|
|
171
182
|
timestamps t
|
@@ -184,7 +195,7 @@ def setup_db
|
|
184
195
|
|
185
196
|
create_table :paranoid_boolean_not_nullables do |t|
|
186
197
|
t.string :name
|
187
|
-
t.boolean :deleted, :boolean, :
|
198
|
+
t.boolean :deleted, :boolean, null: false, default: false
|
188
199
|
end
|
189
200
|
|
190
201
|
create_table :paranoid_belongs_to_polymorphics do |t|
|
@@ -193,36 +204,47 @@ def setup_db
|
|
193
204
|
t.integer :parent_id
|
194
205
|
t.datetime :deleted_at
|
195
206
|
|
196
|
-
t
|
207
|
+
timestamps t
|
197
208
|
end
|
198
209
|
|
199
210
|
create_table :not_paranoid_has_many_as_parents do |t|
|
200
211
|
t.string :name
|
201
212
|
|
202
|
-
t
|
213
|
+
timestamps t
|
203
214
|
end
|
204
215
|
|
205
216
|
create_table :paranoid_has_many_as_parents do |t|
|
206
217
|
t.string :name
|
207
218
|
t.datetime :deleted_at
|
208
219
|
|
209
|
-
t
|
220
|
+
timestamps t
|
221
|
+
end
|
222
|
+
|
223
|
+
create_table :paranoid_no_double_tap_destroys_fullies do |t|
|
224
|
+
t.datetime :deleted_at
|
225
|
+
end
|
226
|
+
|
227
|
+
create_table :paranoid_with_counter_caches do |t|
|
228
|
+
t.string :name
|
229
|
+
t.datetime :deleted_at
|
230
|
+
t.integer :paranoid_boolean_id
|
231
|
+
|
232
|
+
timestamps t
|
210
233
|
end
|
211
234
|
end
|
212
235
|
end
|
236
|
+
# rubocop:enable Metrics/AbcSize
|
237
|
+
# rubocop:enable Metrics/MethodLength
|
213
238
|
|
214
239
|
def timestamps(table)
|
215
|
-
table.column :created_at
|
216
|
-
table.column :updated_at
|
240
|
+
table.column :created_at, :timestamp, null: false
|
241
|
+
table.column :updated_at, :timestamp, null: false
|
217
242
|
end
|
218
243
|
|
219
244
|
def teardown_db
|
220
|
-
|
221
|
-
ActiveRecord::Base.connection.
|
222
|
-
else
|
223
|
-
ActiveRecord::Base.connection.data_sources
|
245
|
+
ActiveRecord::Base.connection.data_sources.each do |table|
|
246
|
+
ActiveRecord::Base.connection.drop_table(table)
|
224
247
|
end
|
225
|
-
tables.each { |table| ActiveRecord::Base.connection.drop_table(table) }
|
226
248
|
end
|
227
249
|
|
228
250
|
class ParanoidTime < ActiveRecord::Base
|
@@ -230,49 +252,92 @@ class ParanoidTime < ActiveRecord::Base
|
|
230
252
|
|
231
253
|
validates_uniqueness_of :name
|
232
254
|
|
233
|
-
has_many :paranoid_has_many_dependants, :
|
234
|
-
has_many :paranoid_booleans, :
|
235
|
-
has_many :not_paranoids, :
|
236
|
-
has_many :paranoid_sections, :
|
255
|
+
has_many :paranoid_has_many_dependants, dependent: :destroy
|
256
|
+
has_many :paranoid_booleans, dependent: :destroy
|
257
|
+
has_many :not_paranoids, dependent: :delete_all
|
258
|
+
has_many :paranoid_sections, dependent: :destroy
|
237
259
|
|
238
|
-
has_one :has_one_not_paranoid, :
|
260
|
+
has_one :has_one_not_paranoid, dependent: :destroy
|
239
261
|
|
240
|
-
belongs_to :not_paranoid, :
|
262
|
+
belongs_to :not_paranoid, dependent: :destroy
|
241
263
|
end
|
242
264
|
|
243
265
|
class ParanoidBoolean < ActiveRecord::Base
|
244
|
-
acts_as_paranoid :
|
266
|
+
acts_as_paranoid column_type: "boolean", column: "is_deleted"
|
245
267
|
validates_as_paranoid
|
246
268
|
validates_uniqueness_of_without_deleted :name
|
247
269
|
|
248
270
|
belongs_to :paranoid_time
|
249
|
-
has_one :paranoid_has_one_dependant, :
|
271
|
+
has_one :paranoid_has_one_dependant, dependent: :destroy
|
272
|
+
has_many :paranoid_with_counter_cache, dependent: :destroy
|
273
|
+
has_many :paranoid_with_custom_counter_cache, dependent: :destroy
|
250
274
|
end
|
251
275
|
|
252
276
|
class ParanoidString < ActiveRecord::Base
|
253
|
-
acts_as_paranoid :
|
277
|
+
acts_as_paranoid column_type: "string", column: "deleted", deleted_value: "dead"
|
254
278
|
end
|
255
279
|
|
256
280
|
class NotParanoid < ActiveRecord::Base
|
257
281
|
end
|
258
282
|
|
283
|
+
class ParanoidNoDoubleTapDestroysFully < ActiveRecord::Base
|
284
|
+
acts_as_paranoid double_tap_destroys_fully: false
|
285
|
+
end
|
286
|
+
|
259
287
|
class HasOneNotParanoid < ActiveRecord::Base
|
260
|
-
belongs_to :paranoid_time, :
|
288
|
+
belongs_to :paranoid_time, with_deleted: true
|
261
289
|
end
|
262
290
|
|
263
291
|
class DoubleHasOneNotParanoid < HasOneNotParanoid
|
264
|
-
belongs_to :paranoid_time, :
|
265
|
-
|
292
|
+
belongs_to :paranoid_time, with_deleted: true
|
293
|
+
begin
|
294
|
+
verbose = $VERBOSE
|
295
|
+
$VERBOSE = false
|
296
|
+
belongs_to :paranoid_time, with_deleted: true
|
297
|
+
ensure
|
298
|
+
$VERBOSE = verbose
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
class ParanoidWithCounterCache < ActiveRecord::Base
|
303
|
+
acts_as_paranoid
|
304
|
+
belongs_to :paranoid_boolean, counter_cache: true
|
305
|
+
end
|
306
|
+
|
307
|
+
class ParanoidWithCustomCounterCache < ActiveRecord::Base
|
308
|
+
self.table_name = "paranoid_with_counter_caches"
|
309
|
+
|
310
|
+
acts_as_paranoid
|
311
|
+
belongs_to :paranoid_boolean, counter_cache: :custom_counter_cache
|
312
|
+
end
|
313
|
+
|
314
|
+
class ParanoidWithCounterCacheOnOptionalBelognsTo < ActiveRecord::Base
|
315
|
+
self.table_name = "paranoid_with_counter_caches"
|
316
|
+
|
317
|
+
acts_as_paranoid
|
318
|
+
if ActiveRecord::VERSION::MAJOR < 5
|
319
|
+
belongs_to :paranoid_boolean, counter_cache: true, required: false
|
320
|
+
else
|
321
|
+
belongs_to :paranoid_boolean, counter_cache: true, optional: true
|
322
|
+
end
|
266
323
|
end
|
267
324
|
|
268
325
|
class ParanoidHasManyDependant < ActiveRecord::Base
|
269
326
|
acts_as_paranoid
|
270
327
|
belongs_to :paranoid_time
|
271
|
-
belongs_to :paranoid_time_with_scope,
|
272
|
-
|
273
|
-
|
328
|
+
belongs_to :paranoid_time_with_scope,
|
329
|
+
-> { where(name: "hello").includes(:not_paranoid) },
|
330
|
+
class_name: "ParanoidTime", foreign_key: :paranoid_time_id
|
331
|
+
belongs_to :paranoid_time_with_deleted, class_name: "ParanoidTime",
|
332
|
+
foreign_key: :paranoid_time_id, with_deleted: true
|
333
|
+
belongs_to :paranoid_time_with_scope_with_deleted,
|
334
|
+
-> { where(name: "hello").includes(:not_paranoid) },
|
335
|
+
class_name: "ParanoidTime", foreign_key: :paranoid_time_id, with_deleted: true
|
336
|
+
belongs_to :paranoid_time_polymorphic_with_deleted, class_name: "ParanoidTime",
|
337
|
+
foreign_key: :paranoid_time_id,
|
338
|
+
polymorphic: true, with_deleted: true
|
274
339
|
|
275
|
-
belongs_to :paranoid_belongs_dependant, :
|
340
|
+
belongs_to :paranoid_belongs_dependant, dependent: :destroy
|
276
341
|
end
|
277
342
|
|
278
343
|
class ParanoidBelongsDependant < ActiveRecord::Base
|
@@ -290,13 +355,14 @@ end
|
|
290
355
|
class ParanoidWithCallback < ActiveRecord::Base
|
291
356
|
acts_as_paranoid
|
292
357
|
|
293
|
-
attr_accessor :called_before_destroy, :called_after_destroy,
|
294
|
-
|
358
|
+
attr_accessor :called_before_destroy, :called_after_destroy,
|
359
|
+
:called_after_commit_on_destroy, :called_before_recover,
|
360
|
+
:called_after_recover
|
295
361
|
|
296
362
|
before_destroy :call_me_before_destroy
|
297
363
|
after_destroy :call_me_after_destroy
|
298
364
|
|
299
|
-
after_commit :call_me_after_commit_on_destroy, :
|
365
|
+
after_commit :call_me_after_commit_on_destroy, on: :destroy
|
300
366
|
|
301
367
|
before_recover :call_me_before_recover
|
302
368
|
after_recover :call_me_after_recover
|
@@ -329,14 +395,14 @@ end
|
|
329
395
|
|
330
396
|
class ParanoidDestroyCompany < ActiveRecord::Base
|
331
397
|
acts_as_paranoid
|
332
|
-
validates :name, :
|
333
|
-
has_many :paranoid_products, :
|
398
|
+
validates :name, presence: true
|
399
|
+
has_many :paranoid_products, dependent: :destroy
|
334
400
|
end
|
335
401
|
|
336
402
|
class ParanoidDeleteCompany < ActiveRecord::Base
|
337
403
|
acts_as_paranoid
|
338
|
-
validates :name, :
|
339
|
-
has_many :paranoid_products, :
|
404
|
+
validates :name, presence: true
|
405
|
+
has_many :paranoid_products, dependent: :delete_all
|
340
406
|
end
|
341
407
|
|
342
408
|
class ParanoidProduct < ActiveRecord::Base
|
@@ -352,22 +418,21 @@ class SuperParanoid < ActiveRecord::Base
|
|
352
418
|
end
|
353
419
|
|
354
420
|
class HasManyInheritedSuperParanoidz < ActiveRecord::Base
|
355
|
-
has_many :super_paranoidz, :
|
421
|
+
has_many :super_paranoidz, class_name: "InheritedParanoid", dependent: :destroy
|
356
422
|
end
|
357
423
|
|
358
424
|
class InheritedParanoid < SuperParanoid
|
359
425
|
acts_as_paranoid
|
360
426
|
end
|
361
427
|
|
362
|
-
|
363
428
|
class ParanoidManyManyParentLeft < ActiveRecord::Base
|
364
429
|
has_many :paranoid_many_many_children
|
365
|
-
has_many :paranoid_many_many_parent_rights, :
|
430
|
+
has_many :paranoid_many_many_parent_rights, through: :paranoid_many_many_children
|
366
431
|
end
|
367
432
|
|
368
433
|
class ParanoidManyManyParentRight < ActiveRecord::Base
|
369
434
|
has_many :paranoid_many_many_children
|
370
|
-
has_many :paranoid_many_many_parent_lefts, :
|
435
|
+
has_many :paranoid_many_many_parent_lefts, through: :paranoid_many_many_children
|
371
436
|
end
|
372
437
|
|
373
438
|
class ParanoidManyManyChild < ActiveRecord::Base
|
@@ -378,21 +443,21 @@ end
|
|
378
443
|
|
379
444
|
class ParanoidWithScopedValidation < ActiveRecord::Base
|
380
445
|
acts_as_paranoid
|
381
|
-
validates_uniqueness_of :name, :
|
446
|
+
validates_uniqueness_of :name, scope: :category
|
382
447
|
end
|
383
448
|
|
384
449
|
class ParanoidBelongsToPolymorphic < ActiveRecord::Base
|
385
450
|
acts_as_paranoid
|
386
|
-
belongs_to :parent, :
|
451
|
+
belongs_to :parent, polymorphic: true, with_deleted: true
|
387
452
|
end
|
388
453
|
|
389
454
|
class NotParanoidHasManyAsParent < ActiveRecord::Base
|
390
|
-
has_many :paranoid_belongs_to_polymorphics, :
|
455
|
+
has_many :paranoid_belongs_to_polymorphics, as: :parent, dependent: :destroy
|
391
456
|
end
|
392
457
|
|
393
458
|
class ParanoidHasManyAsParent < ActiveRecord::Base
|
394
459
|
acts_as_paranoid
|
395
|
-
has_many :paranoid_belongs_to_polymorphics, :
|
460
|
+
has_many :paranoid_belongs_to_polymorphics, as: :parent, dependent: :destroy
|
396
461
|
end
|
397
462
|
|
398
463
|
class ParanoidBaseTest < ActiveSupport::TestCase
|
@@ -400,13 +465,13 @@ class ParanoidBaseTest < ActiveSupport::TestCase
|
|
400
465
|
setup_db
|
401
466
|
|
402
467
|
["paranoid", "really paranoid", "extremely paranoid"].each do |name|
|
403
|
-
ParanoidTime.create! :
|
404
|
-
ParanoidBoolean.create! :
|
468
|
+
ParanoidTime.create! name: name
|
469
|
+
ParanoidBoolean.create! name: name
|
405
470
|
end
|
406
471
|
|
407
|
-
ParanoidString.create! :
|
408
|
-
NotParanoid.create! :
|
409
|
-
ParanoidWithCallback.create! :
|
472
|
+
ParanoidString.create! name: "strings can be paranoid"
|
473
|
+
NotParanoid.create! name: "no paranoid goals"
|
474
|
+
ParanoidWithCallback.create! name: "paranoid with callbacks"
|
410
475
|
end
|
411
476
|
|
412
477
|
def teardown
|
@@ -440,9 +505,9 @@ class ParanoidForest < ActiveRecord::Base
|
|
440
505
|
|
441
506
|
ActiveRecord::Base.logger = Logger.new(StringIO.new)
|
442
507
|
|
443
|
-
scope :rainforest,
|
508
|
+
scope :rainforest, -> { where(rainforest: true) }
|
444
509
|
|
445
|
-
has_many :paranoid_trees, :
|
510
|
+
has_many :paranoid_trees, dependent: :destroy
|
446
511
|
end
|
447
512
|
|
448
513
|
class ParanoidTree < ActiveRecord::Base
|
@@ -451,9 +516,9 @@ class ParanoidTree < ActiveRecord::Base
|
|
451
516
|
validates_presence_of :name
|
452
517
|
end
|
453
518
|
|
454
|
-
class
|
519
|
+
class ParanoidPolygon < ActiveRecord::Base
|
455
520
|
acts_as_paranoid
|
456
|
-
default_scope { where(
|
521
|
+
default_scope { where("sides = ?", 3) }
|
457
522
|
end
|
458
523
|
|
459
524
|
class ParanoidAndroid < ActiveRecord::Base
|
@@ -463,10 +528,14 @@ end
|
|
463
528
|
class ParanoidSection < ActiveRecord::Base
|
464
529
|
acts_as_paranoid
|
465
530
|
belongs_to :paranoid_time
|
466
|
-
belongs_to :paranoid_thing, :
|
531
|
+
belongs_to :paranoid_thing, polymorphic: true, dependent: :destroy
|
467
532
|
end
|
468
533
|
|
469
534
|
class ParanoidBooleanNotNullable < ActiveRecord::Base
|
470
|
-
acts_as_paranoid column:
|
535
|
+
acts_as_paranoid column: "deleted", column_type: "boolean", allow_nulls: false
|
471
536
|
end
|
472
537
|
|
538
|
+
class ParanoidWithExplicitTableNameAfterMacro < ActiveRecord::Base
|
539
|
+
acts_as_paranoid
|
540
|
+
self.table_name = "explicit_table"
|
541
|
+
end
|