SuperAPI AI 工具集

action-mailer-coder

编程与开发

查看项目

更新于 10-16 00:03

技能介绍

用途:在创建或重构 Action Mailer 邮件时,按 Rails 7.1+ 约定组织邮件代码,避免每个邮件一个 mailer 等反模式。

主要能力:将相关邮件分组到同一 mailer;使用参数化 mailer(before_action 中 params.fetch,调用时 NotificationMailer.with(user: user, account: account, comment: comment).comment_reply.deliver_later);通过继承实现动态默认发件地址(default from: -> { build_from_address });后台投递支持 deliver_later、deliver_later(wait: 1.hour)、deliver_later(wait_until: Date.tomorrow.morning);邮件预览类放在 test/mailers/previews/,访问 http://localhost:3000/rails/mailers;使用 I18n.with_locale 做国际化;支持附件与内联附件(attachments.inline["logo.png"]、attachments["invoice.pdf"]);RSpec 测试可断言标题、收件人及 have_enqueued_job(ActionMailer::MailDeliveryJob)。

使用方式:创建 mailer 时输出完整 Mailer 类、HTML 与文本视图、预览类和示例测试用例。

限制:避免 deliver_now 阻塞请求,应使用 deliver_later;避免跳过 .with() 造成隐式依赖;缺少预览类无法可视化测试。以上为公开资料所述内容,未提供具体安装步骤、平台范围或收费信息。