模型有2个关联,每个关联属于同一个“组”,如何将同一个组传递给每个关联?
factory :group_feature_config do
transient do
group
end
association :group_feature, factory: :group_feature, group: group
association :group_user, factory: :group_user, group: group
end
字符串
模型有2个关联,每个关联属于同一个“组”,如何将同一个组传递给每个关联?
factory :group_feature_config do
transient do
group
end
association :group_feature, factory: :group_feature, group: group
association :group_user, factory: :group_user, group: group
end
字符串
2条答案
按热度按时间iecba09b1#
字符串
gtlvzcf82#
我发现这对我很有效:
字符串
假设
group_feature
工厂设置了group