Skip to content

Instantly share code, notes, and snippets.

@victorbueno
Created March 21, 2012 18:53
Show Gist options
  • Save victorbueno/2151241 to your computer and use it in GitHub Desktop.
Save victorbueno/2151241 to your computer and use it in GitHub Desktop.
Background notification
def background_exception_notification(exception, options={})
if @notifier = Rails.application.config.middleware.detect{ |x| x.klass == ExceptionNotifier }
@options = (@notifier.args.first || {}).reverse_merge(self.class.default_options)
@exception = exception
@backtrace = exception.backtrace || []
@sections = @options[:background_sections]
@data = options[:data] || {}
@data.each do |name, value|
instance_variable_set("@#{name}", value)
end
subject = compose_subject(exception)
mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
format.text { render "#{mailer_name}/background_exception_notification" }
end.deliver
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment