On in my production env. I keep getting this error:
ActionView::Template::Error: undefined method `protocol' for nil:NilClass
I can't figure out where this error are in my template, can anybody help me figure this out?
CODE UPDATE
Complete code: Pastebin
I cut out, the area I think might cause problem:
<tr>
<td class="eHeader" style="">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="">
<tr>
<td class="eHeader" style="">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="">
<tr>
<td class="eHeaderLogo" style="">
<a href="#" style="">
<img class="imageFix" src="<%= image_url('crewnetlogo-white.png') %>" width="200" height="48" alt="Crewnet" style="">
</a>
</td>
<!-- end .eHeaderLogo-->
<td class="eHeaderOptions" style="">
</td>
<!-- end .eHeaderOptions-->
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<h1>
<span>
Du er blevet tildelt <%= @workplace.name %>
</span>
</h1>
<div class="bannerLink">
<a href="#" style="">
<img src="<%= image_url "app.png" %>" alt="Crewnet" width="512" height="194" style="">
</a>
</div>
</td>
<!-- end .highlight-->
</tr>
<tr>
<td class="eBody bottomLine" style="">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="entryBox" style="">
<tr>
<td class="width132 pdBt16" style="">
<a href="#" style="">
<img src="<%= image_url "file_icon.gif" %>" width="116" height="116" alt="File" style="">
</a>
</td>
<td class="alignLeft" style="">
<p style="">
Hej <%= @user.name %>!<br>
Du har fået tildelt <%= @workplace.name %> som ansvarsområde. <br>
For mere info log på <a href="<%= workplace_url(@workplace) %>">CrewNet | <%= @workplace.name %></a>.
</p>
<p style="">
Skulle du have nogle spørgsmål, kan du kontakte supporten på <a href="mailto:[email protected]">[email protected]</a>.
<br>
<br>
Teamet bag CrewNet.dk
</p>
</td>
</tr>
</table>
</td>
<!-- end .eBody-->
</tr>
Mailer
class SupervisorMailer < ActionMailer::Base
default from: "[email protected]"
def assigned(user, workplace)
@user = User.find(user)
@workplace = Workplace.find(workplace)
mail to: @user.email, subject: "Du er ansvarlig for #{@workplace.name}."
end
end
production.rb
config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name, :protocol => "http" }
config.action_mailer.asset_host = Rails.application.secrets.domain_name
env
secrets.domain_name = crewnet.dk
To get started, we will first need to create a mailer which is easy to do with Rails' generate mailer command. In this case, the mailer will be used in the OrdersController so we'll name it OrderMailer:
Once the Rails mailer and Gmail settings are properly configured, we can easily send other emails from other controller actions by generating and setting up new mailers in much the same way. :) I just wanted to thank you for writing out this detailed tutorial.
When you call the mail method now, Action Mailer will detect the two templates (text and HTML) and automatically generate a multipart/alternative email. Mailers are really just another way to render a view. Instead of rendering a view and sending it over the HTTP protocol, they are sending it out through the email protocols instead.
Now, in your Rails app mailer settings, replace the <gmail_password> with the new app password instead. If you don't use 2-step verification, you will have to allow your account to be accessed by "less secure apps". In your Google settings under the "Security" tab, look for the "Less secure app access" section and click "Turn on access".
Probably it's realted to url building. Do you have asset_host
setting in your production.rb? Maybe you have to add protocol to asset_host
?
Rails.application.configure do
...
config.action_mailer.asset_host = 'http://example.com'
...
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With