Skip to content

Instantly share code, notes, and snippets.

@erichmachado
Created May 14, 2019 21:46
Show Gist options
  • Save erichmachado/c359dcc22b073fc02e7ac23fdd276cad to your computer and use it in GitHub Desktop.
Save erichmachado/c359dcc22b073fc02e7ac23fdd276cad to your computer and use it in GitHub Desktop.
Interview question
class CommentsController < ApplicationController
def users_comments
posts = Post.all
comments = posts.map(&:comments).flatten
@user_comments = comments.select do |comment|
comment.author.username == params[:username]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment