Removed also ticket history and articles if ticket will be deleted.
This commit is contained in:
parent
c2d7dbd8c9
commit
bd1689ca06
1 changed files with 10 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
class Ticket < ActiveRecord::Base
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue