factory_girl에 문제가 있습니다. 다음은 rspec의 오류입니다.Factory_girl의 오류 : NoMethodError : 정의되지 않은 메소드 - rspec 및 rails 3.1.0
"장애/오류 : 고객 = 공장 (: 고객 : 이름 => 전무) NoMethodError : 정의되지 않은 메서드`category1_id = '#Customer에 대한 : 0x4175418은"
여기 가 RSpec에 코드입니다describe "data integrity" do
it "should return error with no name" do
customer = Factory(:customer, :name => nil)
customer.errors[:name].should_not be_empty
customer.should_not be_valid
end
it "should take a good name" do
customer = Factory(:customer, :name => "good customer name")
customer.errors[:name].should be_empty
end
end
category1_id는 고객 테이블의 열입니다. (: 고객)
Factory.define :customer do |c|
c.name "test customer"
c.email "[email protected]"
c.phone "12345678"
c.cell "1234567890"
c.active 1
c.category1_id 2
c.short_name "test"
end
어떤 생각 여기에 공장에 대한 customer.rb
class Customer < ActiveRecord::Base
validates :name, :presence => true
end
정의는? 감사.
'category'_id' 컬럼이'customer' 테이블에 존재하는지 확인하십시오. – NARKOZ