Ruby on Rails开发全解析:从基础到实战
1. 系统通知器代码示例
在开发过程中,系统通知器是一个重要的组件,它能在系统出现异常时及时通知维护人员。以下是一个修改后的系统通知器代码示例:
# notifier/app/models/system_notifier.rb
require 'pathname'
class SystemNotifier < ActionMailer::Base
SYSTEM_EMAIL_ADDRESS = %{"Error Notifier" <error.notifier@myapp.com>}
EXCEPTION_RECIPIENTS = %w{maintainer@myapp.com support@myapp.com}
def exception_notification(controller, request, exception, sent_on=Time.now)
@subject = sprintf("[ERROR] %s\#%s (%s) %s",
controller.controller_name,
controller.action_name,
exception.class,
exception.message.inspect)
@body = { "controller" => controller, "request" => reque
超级会员免费看
订阅专栏 解锁全文
36

被折叠的 条评论
为什么被折叠?



