Created
November 7, 2016 23:01
-
-
Save tobob/f31762c923cfcd5b786dd41e0b82f6e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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