Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
459 B
Ruby
19 lines
459 B
Ruby
module HtmlBlankable
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
def clears_blank_html(*attributes)
|
|
before_validation do
|
|
attributes.each do |attribute|
|
|
value = public_send(attribute)
|
|
public_send("#{attribute}=", "") if HtmlBlankable.blank_html?(value)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def self.blank_html?(html)
|
|
html.to_s.gsub(/<[^>]*>/, " ").gsub(" ", " ").gsub(/\s+/, " ").strip.blank?
|
|
end
|
|
end
|