Removed also ticket history and articles if ticket will be deleted.

This commit is contained in:
Martin Edenhofer 2012-07-20 10:08:31 +02:00
parent c2d7dbd8c9
commit bd1689ca06

View file

@ -1,5 +1,6 @@
class Ticket < ActiveRecord::Base
before_create :number_generate, :check_defaults
before_create :number_generate, :check_defaults
before_destroy :destroy_dependencies
belongs_to :group
has_many :articles
@ -141,6 +142,14 @@ class Ticket < ActiveRecord::Base
self.owner_id = 1
end
end
def destroy_dependencies
# delete history
History.history_destroy( 'Ticket', self.id )
# delete articles
self.articles.destroy_all
end
class Number
end