1
0

domain_normalizable.rb 342 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. module DomainNormalizable
  3. extend ActiveSupport::Concern
  4. included do
  5. before_validation :normalize_domain
  6. end
  7. private
  8. def normalize_domain
  9. self.domain = TagManager.instance.normalize_domain(domain&.strip)
  10. rescue Addressable::URI::InvalidURIError
  11. errors.add(:domain, :invalid)
  12. end
  13. end