4

:subscriber ファクトリの 'email' 属性値をその関連付け :authentication に渡すにはどうすればよいですか

例:

factory :subscriber, :class => Subscriber do                                                                                                   
  sequence(:name) { |n| "test_user_#{n}" }                                                                                                     
  sequence(:email) { |n| "test_user_#{n}@example.com"}                                                                                                                   
  association :authentication, factory: :authentication, email: email       
end

factory :authentication do
  sequence(:email) { |n| "test_user_#{n}@example.com"} 
  password 'pass'
end

エラーが発生しています

ArgumentError:
   Trait not registered: email
4

1 に答える 1

0

email 変数が変更される可能性があるため、関連付け呼び出しを動的にする必要があると思います。

authentication {association :authentication, email: email}
于 2014-11-25T02:51:47.117 に答える