Project

General

Profile

Actions

Bug #2422

closed

Rails 3.2: before_destroy / dependent => :destroy ordering

Added by Dominic Cleal over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

The ordering of before_destroy and dependent => :destroy is important in Rails 3.2, see:

https://github.com/rails/rails/issues/3458
https://github.com/Katello/katello/pull/2030
https://www.redhat.com/archives/katello-devel/2013-April/msg00196.html

We have a number of models that may be affected:

app/models/user.rb
16:  has_many :usergroup_member, :as => :member, :dependent => :destroy
26:  has_many :user_facts, :dependent => :destroy
48:  before_destroy EnsureNotUsedBy.new(:hosts), :ensure_admin_is_not_deleted

app/models/hostgroup.rb
6:  has_many :hostgroup_classes, :dependent => :destroy
8:  has_many :user_hostgroups, :dependent => :destroy
12:  has_many :group_parameters, :dependent => :destroy, :foreign_key => :reference_id
15:  before_destroy EnsureNotUsedBy.new(:hosts)

app/models/environment.rb
5:  has_many :environment_classes, :dependent => :destroy
13:  has_many :config_templates, :through => :template_combinations, :dependent => :destroy
16:  before_destroy EnsureNotUsedBy.new(:hosts)

app/models/operatingsystem.rb
8:  has_many :images, :dependent => :destroy
14:  has_many :os_default_templates, :dependent => :destroy
19:  has_many :os_parameters, :dependent => :destroy, :foreign_key => :reference_id
20:  has_many :parameters, :dependent => :destroy, :foreign_key => :reference_id, :class_name => "OsParameter" 
29:  before_destroy EnsureNotUsedBy.new(:hosts)

app/models/config_template.rb
12:  has_many :template_combinations, :dependent => :destroy
18:  before_destroy EnsureNotUsedBy.new(:hostgroups, :environments, :os_default_templates)

app/models/subnet.rb
10:  has_many :subnet_domains, :dependent => :destroy
28:  before_destroy EnsureNotUsedBy.new(:hosts, :interfaces )

app/models/puppetclass.rb
3:  has_many :environment_classes, :dependent => :destroy
6:  has_many :hostgroup_classes, :dependent => :destroy
8:  has_many :host_classes, :dependent => :destroy
22:  before_destroy EnsureNotUsedBy.new(:hosts)
23:  before_destroy EnsureNotUsedBy.new(:hostgroups)

app/models/usergroup.rb
4:  has_many :usergroup_members, :dependent => :destroy
10:  before_destroy EnsureNotUsedBy.new(:hosts, :usergroups)

app/models/architecture.rb
5:  has_many :images, :dependent => :destroy
8:  before_destroy EnsureNotUsedBy.new(:hosts)
Actions

Also available in: Atom PDF