item.rb 650 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChecklistTemplate::Item < ApplicationModel
  3. include ChecksClientNotification
  4. include HasDefaultModelUserRelations
  5. belongs_to :checklist_template
  6. # MySQL does not support default value on non-null text columns
  7. # Can be removed after dropping MySQL
  8. before_validation :ensure_text_not_nil, if: -> { ActiveRecord::Base.connection_db_config.configuration_hash[:adapter] == 'mysql2' }
  9. private
  10. # MySQL does not support default value on non-null text columns
  11. # Can be removed after dropping MySQL
  12. def ensure_text_not_nil
  13. self.text ||= ''
  14. end
  15. end