查看规范失败并显示“查询不返回结果集”

发布于 2024-11-04 19:49:51 字数 759 浏览 2 评论 0原文

只是想做一个简单的视图规范。当我第一次创建这个规范并运行它时,它运行得很好。但后来当我需要创建模型类(app/models/request.rb)时,它开始失败并出现以下错误:

失败/错误:渲染 ActionView::模板::错误: 查询不返回结果集

这是我的视图规范:

require 'spec_helper'

describe "requests/new.html.erb" do   

  it "renders a form to reate a request" do  
    assign(:request, mock_model("Request"))  
    render
    rendered.should have_selector("form",
      :method => "post",
      :action => requests_path
    ) do |form|
      form.should have_selector("input",:type=>"submit")
    end
  end
end

这是视图:

<%= form_for @request do |f| %>
  <%= f.submit "Submit" %>
<% end %>

我似乎无法找出问题所在,Google 也没有提供任何帮助。

Just trying to do a simple view spec. When I first create this spec and run it, it worked great. But later on when I needed to create the model class (app/models/request.rb) it starts failing with the following error:

Failure/Error: render
ActionView::Template::Error:
query does not return ResultSet

Here is my view spec:

require 'spec_helper'

describe "requests/new.html.erb" do   

  it "renders a form to reate a request" do  
    assign(:request, mock_model("Request"))  
    render
    rendered.should have_selector("form",
      :method => "post",
      :action => requests_path
    ) do |form|
      form.should have_selector("input",:type=>"submit")
    end
  end
end

Here is the view:

<%= form_for @request do |f| %>
  <%= f.submit "Submit" %>
<% end %>

I can't seem to track down what is wrong and Google offers no help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风铃鹿 2024-11-11 19:49:51

看来问题是模型没有主动迁移。初学者的错误。

It appears it was a problem that there was no active migration for the model. Beginner mistake.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文