- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在从根路径上的某些 IP 地址进行生产时,我随机收到此错误。 rails 应用程序不支持格式 :formats=>[:gif, "image/x-xbitmap", :jpeg, "image/pjpeg", "application/x-shockwave-flash", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/msword"]
因此,如果为他们提出请求,似乎会出现此错误。我猜有人或某个机器人正试图对该站点运行漏洞利用——我如何将这些类型的请求重定向或路由回路由路径,以便不会产生错误?
ActionView::MissingTemplate: Missing template front_page/index, application/index with {:locale=>[:en], :formats=>[:gif, "image/x-xbitmap", :jpeg, "image/pjpeg", "application/x-shockwave-flash", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/msword"], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder]}. Searched in:
* "/app/app/views"
* "/app/vendor/bundle/ruby/2.0.0/gems/activeadmin-1.0.0.pre2/app/views"
* "/app/vendor/bundle/ruby/2.0.0/gems/kaminari-0.16.3/app/views"
* "/app/vendor/bundle/ruby/2.0.0/gems/devise-3.5.2/app/views"
File "/app/vendor/bundle/ruby/2.0.0/gems/actionview-4.2.4/lib/action_view/path_set.rb", line 46, in find
File "/app/vendor/bundle/ruby/2.0.0/gems/actionview-4.2.4/lib/action_view/lookup_context.rb", line 121, in find
File "/app/vendor/bundle/ruby/2.0.0/gems/actionview-4.2.4/lib/action_view/renderer/abstract_renderer.rb", line 18, in find_template
最佳答案
要在您的评论中获得所需的结果:
constraints :format => "html" do
resources ...
end
# application_controller.rb
ApplicationController < ActionController::Base
before_action :check_format!
...
def check_format!
unless request.format == :html
render :nothing status: :bad_request
end
end
...
end
respond_to
的桶是非常典型的。在 Controller 中,因为正常行为是尝试提供任何格式。否则,可能会有大量的配置等。
Is there a way to do this for all controller actions unless explicitly stated
unless explicitly stated
你有点逆流而上。
关于ruby-on-rails - Rails ActionView::MissingTemplate 用于不应该存在的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35944734/
将 mysite 部署到 VPS 后,我面临此运行时错误。请注意,在我的本地机器上,一切正常。 当我尝试通过 Controller 路由访问任何 View 时,可以说 PostsController#
我在 Rails 中遇到一些路由问题。 我已经为 Project 模型准备了一个模型,所以我使用 rails generate scaffold_controller 生成了一些默认 Controll
当 Google 机器人尝试访问我的某个 Controller 时,我收到此错误消息。 ActionView::MissingTemplate: Missing template channels/s
我正在测试 Rails Controller 并尝试使用代码执行获取: delete :remove_logs, :id => 3 它始终返回一个 ActionView::MissingTemplat
现在,我不得不承认,我是 Ruby on Rails 的新手,并不是很了解每个概念。我已经安装了 Devise 进行身份验证并遵循了 this guide在我的 View 中包含注册和登录链接。 这是
我的 Rails 应用程序从 Rails 6 升级到 Rails 7 后遇到问题。当我尝试 render_to_string 模板时,我收到 ActionView::MissingTemplate 异
我已经使用 capistrano 部署了我的应用程序在 AWS , 与 nginx和 unicorn .当我打开我的主页时,它是空的。这是我的unicorn日志 Started GET "/" for
在从根路径上的某些 IP 地址进行生产时,我随机收到此错误。 rails 应用程序不支持格式 :formats=>[:gif, "image/x-xbitmap", :jpeg, "image/pjp
我收到一个我无法弄清楚的错误: ActionView::MissingTemplate (Missing template cluster/delete_stuff.erb in view path
我有一个为我的主页提供服务的操作。它在正常访问时工作正常(即由网络浏览器中的用户访问),但是当被特定的网络爬虫访问时,它会抛出以下错误: A ActionView::MissingTemplate
我有一个 Rails 3.2 项目。我还使用 haml 作为我的模板引擎,但我决定使用 slim 而不是 haml。所以我用 slim 重写了一些 View 。但是当我将此更改推送到服务器时,我在生产
我有一个简单的角轨应用程序,我正在尝试将其连接起来。 这是我的 Rails Controller : class ItemsController false } end end
我正在尝试进行 ajax 调用,但我不想返回任何数据,或者可能只返回 200。 我的错误是 ActionView::MissingTemplate (Missing template .... 我在
我想使用本教程将 AJAX 搜索字段添加到我的应用程序:http://www.rymcmahon.com/articles/11 除搜索 JS 字段外,一切正常。它根本不起作用。我的终端控制台中的错误
在我的一个 Controller 中,我有以下代码: respond_to do |format| format.html{ redirect_to :me, :flash => {:error
升级到 Rails 3.1.0 和以下版本后 David Rice's instructions ,奇怪的是,我所有的 Controller 都找不到他们的 View 了。 # rails s # S
我正在尝试在我的 Rails 应用程序上使用 Rsec 测试一些非常简单的东西。 这是spec/controllers/movies_controller_spec.rb中的测试代码 describ
我正在尝试为 Ruby on Rails 开发一个插件,但在渲染 html View 时遇到了问题。我的目录结构如下所示: 文件结构 ---/vendor |---/plugins
我正在尝试使用 Rails 进行 AJAX 调用。该调用是对我 Controller 中的 change_profile 操作的调用。该 Action 的内容如下: def change_profil
我一直在我的日志中看到类似于以下内容的错误。 谁能告诉我为什么我会间歇性地收到这样的错误?是缓存问题吗? 每次我尝试加载关于我们的页面时,它都能完美加载,但每隔几天我的日志中就会出现这样的错误,但它并
我是一名优秀的程序员,十分优秀!