name_tw = Array.new 51,"" name_tw = name_tw.map do |p| Faker::Name::name end name_en = Array.new 51,"" name_en = name_en.map do |p| Faker::Name::name end email = Array.new 51,"" email= email.map do |p| Faker::Internet.email end FactoryGirl.define do factory(:conference_co_author, class: "ConferenceCoAuthor") do |f| f.sequence(:co_author_translations) do |n| { zh_tw: "#{name_tw[n]}", en: "#{name_en[n]}" } end f.sequence(:conference_co_author_relations_id) do |n| "#{ConferenceCoAuthorRelation.all[n%ConferenceCoAuthorRelation.count].id}" end f.sequence(:email) do |n| "#{email[n]}" end f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account end end