视图规范因“查询不返回结果集"而失败; [英] view spec fails with "Query does not return ResultSet"

查看:34
本文介绍了视图规范因“查询不返回结果集"而失败;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

失败/错误:渲染动作视图::模板::错误:查询不返回 ResultSet

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

这是我的视图规范:

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 也不提供任何帮助.

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

推荐答案

似乎是模型没有活动迁移的问题.初学者错误.

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

这篇关于视图规范因“查询不返回结果集"而失败;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆