1
无论出于何种原因,我无法弄清楚为什么我不断收到此错误。在新的日志中显示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/[email protected]_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' %>
不知道其他人在这里做什么。我错过了什么?
好奇,为什么格式是'png'? – dubadub
说实话我不知道! –
这是通过渲染在某个视图中调用的吗?你可以发布视图的代码,这是调用?此外,它以前是否工作过,现在已经破产? –