jam-cloud/ruby/lib/jam_ruby/models/email_batch_set.rb

24 lines
634 B
Ruby

module JamRuby
class EmailBatchSet < ActiveRecord::Base
self.table_name = "email_batch_sets"
belongs_to :email_batch, :class_name => 'JamRuby::EmailBatch'
def self.deliver_set(batch_id, user_ids)
bset = self.new
bset.email_batch_id = batch_id
bset.user_ids = user_ids.join(',')
bset.started_at = Time.now
bset.batch_count = user_ids.size
bset.save!
if 'test' == Rails.env
BatchMailer.send_batch_email(bset.email_batch_id, user_ids).deliver!
else
BatchMailer.send_batch_email(bset.email_batch_id, user_ids).deliver
end
bset
end
end
end