rails发送在按钮中具有href链接的电子邮件

时间:2017-02-12 23:15:14

标签: ruby-on-rails email

我发送一封确认电子邮件(现在可以使用!),在电子邮件中,我希望链接显示为按钮。

我试过了:

<p><%= link_to t('.action', default: 'Confirm my account'),
         confirmation_url(@resource, confirmation_token: @token, locale: I18n.locale), class: "btn btn-primary" %></p>

我附加了,类:“btn btn-primary”,但它没有用。 什么是正确的方法?

我有自举安装并在我的应用程序中工作。我听说你需要在你的电子邮件中引用bootstrap,但是怎么做?

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
</head>
<body> 

<p><%= link_to t('.action', default: 'Confirm my account'), confirmation_url(@resource, confirmation_token: @token, locale: I18n.locale), class: "btn btn-primary" %></p>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

不确定,为什么 bootstrap 无效,因为它将<div class="row"> <div class="col-md-4"> <div class="slide-swapper"> <img src="images/gray.jpg" class="img-fluid gray" height="360" width="360" alt="gray"> <img src="images/silver.jpg" class="img-fluid silver" height="360" width="360" alt="silver"> </div> <div class="color-group"> <input id="input-1" type="radio" checked="checked" name="change-image"> <label for="input-1" title="gray">Gray</label> <input id="input-2" type="radio" name="change-image"> <label for="input-2" title="silver">Silver</label> </div> </div> </div> <style> .slide-swapper { position: relative; height: 360px; margin-bottom: 30px; } img { position: absolute; top: 0; left: 0; } </style> 类添加到标记中。但是,如果您不想依赖现有样式,请将链接显示为电子邮件中的一个按钮,您只需使用css.Try添加此类。还可以删除btn标记。

p

更多示例是here