Sha256: 38d02be4410e48a163e96429c0487d27e6c0ba85296692abd0bb3db8e513900c
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# A ContactEmail is a one time mail generated from an EmailTemplate, sent not to a # list, but to a set of user_ids. # class ContactEmail < Email include ScheduledEmail before_save :generate_html_body_from_text_body # NOTE perhaps contact_email should validate contact ids? Then again, # then it would be necessary to ensure the contacts had primary email # addresses validates :user_ids, :presence => true after_create :send_to_user_ids class << self def new_from_template(template, attrs = {}) new({ :name => "#{template.name} - #{DateTime.now.to_i}", :subject => template.subject, :html_body => template.html_body, :text_body => template.text_body }.merge(attrs)) end end attr_reader :user_ids # user_ids only gets set if it's an array or a properly formatted string def user_ids=(val) @user_ids = case val when /^\[?((\d+,?\s?)+)\]?$/ $1.split(',') when Array val else [] end @user_ids.map!(&:to_i) end protected def send_to_user_ids Rails.logger.info("ContactEmail##{id} sending to user ids #{user_ids}") send!(user_ids) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
e9_crm-0.1.1 | app/models/contact_email.rb |