我正在使用2颗宝石
1)delayed_job_active_record
2)letter_opener
我试图在5分钟后向特定用户发送邮件。所以邮件正在发送,但我得到的回复是'rich.html.erb',它会自动打开我的崇高文本。我需要一种方式所以它应该用我的浏览器打开。那该怎么办?
[delayed_job.rb]
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
[User.rb]
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
after_save :user_email
def user_email
Usermailer.delay.user_mail('raghavvishnoi10@gmail.com')
end
end
[usermailer.rb]
class Usermailer < ActionMailer::Base
default from: "from@example.com"
def user_mail(email)
mail(to: email,subject: "hello")
end
end
基本上这个文件在我的崇高文本中自动打开。我想用浏览器打开这个文件
[rich.html]
<title>hello</title>
<style type="text/css">
#container {
margin: 10px auto;
}
#message_headers {
background: #fff;
font-size: 12px;
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
border-bottom: 1px solid #dedede;
margin-bottom: 10px;
overflow: auto;
}
#message_headers dl {
float: left;
line-height: 1.3em;
padding: 0;
}
#message_headers dt {
width: 92px;
margin: 0;
float: left;
text-align: right;
font-weight: bold;
color: #7f7f7f;
}
#message_headers dd {
margin: 0 0 0 102px;
}
#message_headers p.alternate {
float: right;
margin: 0;
}
#message_headers p.alternate a {
color: #09c;
}
pre#message_body {
padding: 4px;
white-space: pre-wrap;
border: 1px solid #eee;
background-color: #fcfcfc;
}
iframe {
border: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container">
<div id="message_headers">
<dl>
<dt>From:</dt>
<dd>from@example.com</dd>
<dt>Subject:</dt>
<dd><strong>hello</strong></dd>
<dt>Date:</dt>
<dd>Nov 30, 2015 05:33:46 PM IST</dd>
<dt>To:</dt>
<dd>raghavvishnoi10@gmail.com</dd>
</dl>
</div>
<iframe seamless="seamless" srcdoc="<base target='_top'>hello"></iframe>
</div>
</body>
</html>
答案 0 :(得分:1)
删除.erb扩展名,以便文件以.html结尾。然后,您可以将其拖到浏览器窗口中,在浏览器中打开它。
答案 1 :(得分:0)
发生这种情况是因为letter_opener文件生成的.html是使用代码编辑器而非浏览器打开的,您可以更改系统中的默认配置,以在打开.html文件时使用浏览器