Issue
I am using 2 gems
1) delayed_job_active_record
2) letter_opener
I am trying to send a mail to a particular user after 5 minutes.So the mail is sending but the response which I am getting is in 'rich.html.erb' which is opening automatically with my sublime text.And I need a way so that it should be opened with my browser.So what to do?
[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('[email protected]')
end
end
[usermailer.rb]
class Usermailer < ActionMailer::Base
default from: "[email protected]"
def user_mail(email)
mail(to: email,subject: "hello")
end
end
And basically this file is opening automatically in my sublime text.I want this file to be open with my browser
[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>[email protected]</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>[email protected]</dd>
</dl>
</div>
<iframe seamless="seamless" srcdoc="<base target='_top'>hello"></iframe>
</div>
</body>
</html>
Solution
Get rid of the .erb extension, so that the file ends with .html. Then you can open it in your browser by dragging it into a browser window.
Answered By - bo-oz Answer Checked By - Marilyn (WPSolving Volunteer)