【问题标题】:Rails Rendering: Intermittent Resource not found (ActionView::TemplateError)Rails 渲染:找不到间歇性资源 (ActionView::TemplateError)
【发布时间】:2009-08-12 18:06:16
【问题描述】:

我可以使用一些帮助来弄清楚发生了什么。检查下面的日志输出——为什么 rails 会以不同的方式处理这两个渲染?为什么一个成功,没有任何相关的 SQL 调用,而第二个失败 - 使用 SQL 访问。 (它不是 ActiveRecord 模型,此渲染中不应涉及 SQL。)

背景

我有一个黄瓜功能,有两个场景,每个场景都依赖 Webrat 来解决步骤“当我转到文章列表时”。文章模型不是 ActiveRecord 模型,不应依赖 SQL 进行访问。

如果我在文件中对场景 #1、#2 进行排序,则第一个场景通过所有测试,而第二个场景如预期的那样在稍后的不同步骤中失败。

如果我在文件中订购场景#2、#1,则在通过相关步骤后,#2 场景会按预期失败。但是#1 场景现在无法通过“当我转到文章列表时”步骤:

找不到资源 (ActionView::TemplateError) features/article.feature:23:in `当我进入文章列表时'

test.log 内容

-------- webrat 测试成功 - 非 db 支持的模型 --------------

Processing ArticlesController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
Rendering template within layouts/application
Rendering articles/index
Completed in 9ms (View: 6, DB: 0) | 200 OK [http://www.example.com/ccc/articles]
REQUESTING PAGE: GET /ccc/articles/new with {} and HTTP headers {"HTTP_REFERER"=>"/ccc/articles"}

-------- webrat 测试失败 ---------

Processing ArticlesController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
Rendering template within layouts/application
Rendering articles/index


Processing ApplicationController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
      ^[[4;35;1mSQL (0.1ms)^[[0m   ^[[0mROLLBACK^[[0m

【问题讨论】:

    标签: ruby-on-rails ruby rendering cucumber


    【解决方案1】:

    为了排除一些可能性:将paths.rb中的文章索引页面的位置更改为“/test.html”之类的内容,并将该文件放在“/public”中——看看步骤是否相同行为。如果他们这样做了,那么您的测试设置/拆卸操作之一很可能会出现问题。如果他们不这样做,我会查看操作本身的逻辑和模板的内容以了解可能发生的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-15
      • 2010-12-15
      • 2011-07-03
      • 2011-05-10
      • 1970-01-01
      • 1970-01-01
      • 2020-08-30
      • 1970-01-01
      相关资源
      最近更新 更多