缺少模板错误 - 布局存在时

时间:2017-04-03 17:44:46

标签: ruby-on-rails ruby actionview

无论出于何种原因,我无法弄清楚为什么我一直收到这个错误。在一个新的日志上,它会显示8次,这很奇怪。

我在本地设置的生产环境中运行WEBrick。但是我在AWS上运行Puma的实际生产环境中收到了同样的错误。

ruby 2.1.4p265
rails 4.2.7.1

栈跟踪

Error during failsafe response: Missing template errors/internal_server_error, 
application/internal_server_error with {:locale=>[:en], :formats=>[:png], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby]}. Searched in:
  * "~/Rails/ReturnLabel/return_label/app/views"
  * "~/.rvm/gems/ruby-2.1.4@return_disposition/gems/devise-3.5.5/app/views"

应用程序/视图/错误

$ ls app/views/errors/
./                              _error.html.erb                 internal_server_error.html.erb  no_label.html.erb               unsupported_country.html.erb
../                             expired_order.html.erb          invalid.html.erb                not_found.html.erb

errors_controller.rb

class ErrorsController < ApplicationController
  def expired_order
    @error = :expired_order
    render(status: 503)
  end
  def unsupported_country
    @error = :unsupported_country
    render(status: 503)
  end
  def invalid
    @error = :invalid
    render(status: 400)
  end
  def not_found
    @error = :not_found
    render(status: 404)
  end
  def internal_server_error
    @error = :internal_server_error
    render(status: 500)
  end
  def no_label
    @error = :no_label
    render(status: 503)
  end
end

的routes.rb

 match '/404', to: 'errors#not_found', as: 'not_found', via: :all
 match '/500', to: 'errors#internal_server_error', as: 'internal_server_error', via: :all
 match '/unsupported_country', to: 'errors#unsupported_country', via: :all
 match '/expired_order', to: 'errors#expired_order', via: :all
 match '/invalid', to: 'errors#invalid', via: :all
 match '/no_label', to: 'errors#no_label', via: :all
 ...
 # END OF FILE
 match '*path', to: 'errors#not_found', via: :all

查看代码

internal_server_error.html.erb

<header class="header-span-single-line styled">
  <div class="text-center animated shake">
    <span><%= t('error.header.title') %></span>
    <br>
  </div>
</header>
<div class="container animated bounceInUp">
  <div class="jumbotron">
    <div class="container">
      <%= render 'error' %>
    </div>
  </div>
</div>

_error.html.erb

<% error_text = t("error.#{@error}") %>
<h1><%= error_text[:title] %></h1>
<p class="text-white"><%= error_text[:body] %></p>
<hr/>
<p><strong><%= t('error.contact.title') %></strong></p>
<ul class="list-padding">
  <li class="list-unstyled">
    <p class="cs-p"><%= t('error.contact.phone') %></p>
  </li>
  <li class="list-unstyled">
    <p class="cs-p"><%= t('error.contact.email.title') %>
      <a class="branded-link branded-link-dark" target="_blank" href="<%= t('error.contact.email.href') %>"><%= t('error.contact.email.value') %></a>
    </p>
  </li>
</ul>
<%= link_to t('error.button'), :root, :class => 'btn btn-warning btn-lg btn-dark' %>

不知道还有什么可以做的。我错过了什么?

1 个答案:

答案 0 :(得分:0)

看来你获得png图片时出现500错误。因此,您的应用会尝试重定向到您的internal_server_error操作,但无法找到internal_server_error.png文件。

使用png图片搜索您的观看过期的img代码或image_tag来电和url()的css,然后删除或更新它们。