簡體   English   中英

生產中郵件中的Rails4模板錯誤

[英]Rails4 template error in mailer in production

在我的生產環境中。 我一直收到這個錯誤:

ActionView::Template::Error: undefined method `protocol' for nil:NilClass

我無法弄清楚我的模板中出現此錯誤的位置,有人可以幫我解決這個問題嗎?

代碼更新

完整代碼: Pastebin

我剪掉了,我覺得這個區域可能會引起問題:

<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:support@crewnet.dk">support@crewnet.dk</a>.

                <br>
                <br>
                Teamet bag CrewNet.dk
              </p>
              </td>
          </tr>
        </table>
        </td>
      <!-- end .eBody--> 
    </tr>

信封

class SupervisorMailer < ActionMailer::Base
  default from: "support@crewnet.dk"

    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

可能它是建築物的網址。 你的asset_host中有asset_host設置嗎? 也許你必須將協議添加到asset_host

Rails.application.configure do
  ...
  config.action_mailer.asset_host = 'http://example.com'
  ...
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM