You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is in relation to Photogram Industrial Part 2, when it is time to generate sample data.
With the Follow Requests, I noticed when running the provided code that it had users following themselves, which seems like unintentional behavior and causes the task to take longer than it should.
I solved this by adding next if first_user == second_user to the sample data generation task:
users.each do |first_user|
users.each do |second_user|
next if first_user == second_user
I also added the following custom validation to the follow_requests table:
validate :sender_cant_follow_self
def sender_cant_follow_self
if sender_id == recipient_id
errors.add(:sender_id, "can't follow self")
end
end
The text was updated successfully, but these errors were encountered:
This is in relation to Photogram Industrial Part 2, when it is time to generate sample data.
With the Follow Requests, I noticed when running the provided code that it had users following themselves, which seems like unintentional behavior and causes the task to take longer than it should.
I solved this by adding
next if first_user == second_user
to the sample data generation task:I also added the following custom validation to the follow_requests table:
The text was updated successfully, but these errors were encountered: