case
When user updates to teacher_account Create user_performance as related data.
user_performance uses polymorphic related
code
FactoryBot.define do
factory :user do
sequence(:username) { |n| "Testuser#{n}" }
sequence(:email) { |n| "tester#{n}@example.com" }
password { 'password' }
phone_number { "0#{rand(0..9)}0#{rand(1_000_000..99_999_999)}" }
confirmed_at { Date.today }
trait :teacher_account do
teacher { true }
after(:create) do |user|
create(:user_performance, performancable: user)
end
end
end
end
Recommended Posts