Empresa activa
Q. There are a couple of errors with this Ruby code. What are they? users = User.where(active: true) Post = [ ] users.each do |user| Post << user.posts end
Anónimo
A. The interviewer said that the only problem was that there are actually a million users and it's not optimized. The answer the interviewer provided: posts = Post.joins(:user).where(active: true) users = User.where(active: true).includes(:posts)