app/models/voltron/notification/email_notification.rb in voltron-notify-0.2.0 vs app/models/voltron/notification/email_notification.rb in voltron-notify-0.2.1
- old
+ new
@@ -1,8 +1,8 @@
class Voltron::Notification::EmailNotification < ActiveRecord::Base
- belongs_to :notification
+ belongs_to :notification, inverse_of: :email_notifications
after_initialize :setup
before_create :send_now, if: Proc.new { |n| !n.send(:use_queue?) || n.immediate }
@@ -52,11 +52,11 @@
@mailer_arguments = *args
end
def template(fullpath)
parts = fullpath.split('/')
- self.template_name = parts.pop.sub(/\.(html|text)\..*$/, '')
+ self.template_name = parts.pop.sub(/\.[a-z_]+\.[^\.]+$/i, '')
self.template_path = parts.join('/')
end
def deliver_now
@delivery_method = :deliver_now
@@ -97,10 +97,10 @@
@vars ||= {}
@attachments ||= {}
@mailer_arguments = nil
self.mailer_class ||= Voltron.config.notify.default_mailer
self.mailer_method ||= Voltron.config.notify.default_method
- template(Voltron.config.notify.default_template)
+ template(Voltron.config.notify.default_template) if self.template_name.blank? || self.template_path.blank?
end
def mail_options
@mail_options ||= {}
end
\ No newline at end of file