首页 > 解决方案 > 如何使 DecentExposure gem 在邮件上工作?

问题描述

我正在尝试expose在 Ruby on Rails 邮件程序中包含 Decent Exposure 方法,但我不断收到此错误:NoMethodError - undefined method params' for #

我知道 gem 正在寻找控制器参数,这些参数在 ActionMailer 中不可用。但是,他们的文档说它适用于邮件程序。

我的代码与他们文档中的代码非常相似:

class UserMailer < ApplicationMailer
  expose(:user)

  def welcome_email(id:)
    mail(to: user.email, from: "...", subject: "...")
  end
end

我正在使用 Ruby 2.5.0、Rails 5.0.7.2 和 DecentExposure 3.0.0

标签: ruby-on-railsruby

解决方案


推荐阅读