我有工厂女孩和协会的问题。
NameError: uninitialized constant User::DefaultDeviceX
用户工厂:
FactoryGirl.define do
factory :user do
name "MyString"
email "MyString"
password "MyString"
association :default_device_x, factory: :device
association :default_device_y, factory: :device
end
end
执行FactoryGirl.create(:user)会引发上面提到的错误。
那么,我做错了什么?
用户模型引用设备:
belongs_to :default_device_x
belongs_to :default_device_y
设备工厂
FactoryGirl.define do
factory :device do
name "Device 1"
comments "Comment"
end
end