7

我有带有布局的 project_mailer,但如果 project_notification 方法具有参数 that ,我想使用不同的方法unsubscribe_link = true

layout "project_mail"

def project_notification(user, projects, unsubsribe_link = false)
  attachments.inline['logo_252.png'] = File.read(Rails.root + 'public/images/logo_252.png')
  @user = user
  @projects = projects

  mail(:to => user.email, :subject => "New Projects")
end
4

1 回答 1

17

我假设你已经解决了你的问题,我回答是为了帮助别人:

layout 'project_mail'

def project_notification(user, projects, unsubscribe_link = false)
  attachments.inline['logo_252.png'] = File.read(Rails.root + 'public/images/logo_252.png')
  @user = user
  @projects = projects
  layout_name = unsubscribe_link ? 'other_fancy_layout' : 'project_mail'

  mail(to: user.email, subject: "New Projects") do |format|
    format.html { render layout: layout_name }
    format.text { render layout: layout_name }
  end
end
于 2013-10-25T14:16:50.873 回答