2013-07-07 47 views
0

我使用Rails 3.2.13,Ruby 2.0.0p-p247和Spree 2.0.3。Rails activerecord .select使对象具有所有的零属性

使用ActiveRecord在轨控制台,或在我的实际应用程序,如果我跑:Spree::Product.select(:permalink).first我得到#<Spree::Product permalink: nil>

但是,如果我跑Spree::Product.first.permalink我得到"test",预期固定链接。此外,Spree::Product.first会返回产品的整个活动记录关系。

我试着在RAILS_ENV=development rails c中运行Spree::Product.create(name: "test", price: "100"),它按预期工作。如果我在RAILS_ENV=test rails c尝试,我得到一个SQL回滚,并NoMethodError: undefined method '[]' for nil:NilClass

任何想法为什么这只发生在测试环境?

+1

您的测试数据库是最新的吗? –

回答

相关问题