app/models/mail_manager/contact.rb in mail_manager-3.2.7 vs app/models/mail_manager/contact.rb in mail_manager-3.2.22.0

- old
+ new

@@ -8,18 +8,26 @@ #accepts_nested_attributes_for :subscriptions validates_presence_of :email_address #validates_format_of :email_address, :with => Authentication.email_regex, # :message => Authentication.bad_email_message, :allow_nil => true - validates_format_of :email_address, :with => /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/, :allow_nil => true + validates_format_of :email_address, :with => /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i, :allow_nil => true + before_validation :trim_fields + include MailManager::ContactableRegistry::Contactable include Deleteable attr_protected :id def contact self + end + + def trim_fields + [:first_name, :last_name, :email_address].each do |field| + self[field].gsub!(/\A\s*|\s*\Z/,'') if self[field].present? + end end scope :search, lambda{|params| conditions = ["deleted_at IS NULL"] joins = {}