Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to properly randomize data with seed.rb using Factory Girl and random_data?
- require 'factory_girl_rails'
- 50.times do
- @user = FactoryGirl.create(:user)
- FactoryGirl.create(:contact, :user => @user)
- @question = FactoryGirl.create(:question, :user => @user)
- FactoryGirl.create(:user_answer, :question => @question, :authorable => @user)
- @contact = FactoryGirl.create(:contact, :user => @user)
- FactoryGirl.create(:contact_answer, :question => @question, :authorable => @contact)
- end
- FactoryGirl.define do
- factory :question do
- title "What is the best place to travel in " + Random.country + "?"
- body Random.paragraphs(2)
- association :user, :method => :build
- end
- end
- Faker::Name.name
- Faker::Address.uk_country
- Faker::Lorem.paragraph
Advertisement
Add Comment
Please, Sign In to add comment