7

レイアウト付きの project_mailer がありますが、 project_notification メソッドにそのパラメーターがある場合は、別のメソッドを使用したいと考えています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 に答える