Skip to content

Commit

Permalink
Delete resource_action of cb as well
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Oct 31, 2018
1 parent e391dec commit 18245f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class CustomButton < ApplicationRecord
validates :name, :description, :uniqueness => {:scope => [:applies_to_class, :applies_to_id]}, :presence => true
validates :guid, :uniqueness => true, :presence => true

after_destroy :cleanup_resource_actions

include UuidMixin
acts_as_miq_set_member

Expand Down Expand Up @@ -238,4 +240,10 @@ def self.display_name(number = 1)
def open_url?
options[:open_url] == true
end

private

def cleanup_resource_actions
resource_action.destroy
end
end
2 changes: 1 addition & 1 deletion app/models/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def dialog_field_hash

def reject_if_has_resource_actions
if resource_actions.length > 0
raise _("Dialog cannot be deleted because it is connected to other components.")
raise _("Dialog cannot be deleted because it is connected to other components: #{resource_actions.each.pluck(:resource_id, :resource_type).flatten}")
end
end

Expand Down

0 comments on commit 18245f0

Please sign in to comment.