首页 > 解决方案 > 在 Rails 邮件模板中使用 link_to 创建的链接不可点击

问题描述

在我的邮件中,我正在形成如下链接

class CustomerMailer < ApplicationMailer
  def magic_login_email
    customer = params[:customer]
    @customer_login_url =  magic_login_url(customer.authentication_token)

    mail(to: customer.email, subject: "Here's your login link")
  end
end

我在模板中使用它如下

<html>
  <head>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  </head>
  <body>
    <h1>Here's your login link</h1>
    <p>
      You have successfully signed up.<br>
    </p>
    <p>
      To login to the site, just follow this link: <%= link_to 'Log in now', @customer_login_url %>.
    </p>
    <p>Thanks for joining and have a great day!</p>
  </body>
</html>

但是当我在 gmail 中打开这封电子邮件时,我无法点击链接。该链接似乎是文本。谁能帮我解决这个问题。提前致谢。

标签: ruby-on-rails

解决方案


推荐阅读