has_links.rb 421 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. module HasLinks
  3. extend ActiveSupport::Concern
  4. included do
  5. before_destroy :links_destroy
  6. end
  7. =begin
  8. delete object link list, will be executed automatically
  9. model = Model.find(123)
  10. model.links_destroy
  11. =end
  12. def links_destroy
  13. Link.remove_all(
  14. link_object: self.class.to_s,
  15. link_object_value: id,
  16. )
  17. end
  18. end