Skip to content

Instantly share code, notes, and snippets.

@tobob
Created November 7, 2016 23:01
Show Gist options
  • Save tobob/f31762c923cfcd5b786dd41e0b82f6e2 to your computer and use it in GitHub Desktop.
Save tobob/f31762c923cfcd5b786dd41e0b82f6e2 to your computer and use it in GitHub Desktop.
ok = false
while(!ok)
users_list_ids = User.all.pluck(:id).shuffle
User.all.each_with_index do |user, index|
user.update_attribute(:target_id, users_list_ids[index])
end
ania_ok = User.find_by(name: 'Ania').target.name != 'Damian'
damian_ok = User.find_by(name: 'Damian').target.name != 'Ania'
asia_ok = User.find_by(name: 'Asia').target.name != 'Mateusz'
mateusz_ok = User.find_by(name: 'Mateusz').target.name != 'Asia'
if ania_ok && damian_ok && mateusz_ok && asia_ok
ok = true
else
p "Jeszcze raz"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment