32 lines
641 B
Ruby
32 lines
641 B
Ruby
class MailCron
|
|
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
|
|
|
|
field :mail_from_app
|
|
field :mail_from
|
|
field :mail_to
|
|
field :mail_reply_to
|
|
field :mail_subject
|
|
field :mail_content, :type => Hash
|
|
field :mail_sentdate , :type => DateTime
|
|
|
|
field :create_user_id
|
|
field :update_user_id
|
|
|
|
has_many :mail_cron_files, :autosave => true, :dependent => :destroy
|
|
|
|
accepts_nested_attributes_for :mail_cron_files, :allow_destroy => true
|
|
|
|
after_save :save_mail_cron_files
|
|
|
|
|
|
def save_mail_cron_files
|
|
self.mail_cron_files.each do |t|
|
|
if t.should_destroy
|
|
t.destroy
|
|
end
|
|
end
|
|
end
|
|
end |