Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
module Auditable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
belongs_to :created_by, class_name: "User", optional: true
|
||||
belongs_to :updated_by, class_name: "User", optional: true
|
||||
|
||||
before_create :set_created_by
|
||||
before_save :set_updated_by
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_created_by
|
||||
self.created_by_id ||= Current.user&.id
|
||||
end
|
||||
|
||||
def set_updated_by
|
||||
self.updated_by_id = Current.user&.id if Current.user
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
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
|
||||
Reference in New Issue
Block a user