Skip to content

Instantly share code, notes, and snippets.

@3den
Created November 30, 2017 22:23
Show Gist options
  • Save 3den/f7c55d0bcd9d809fdbe7f3da4fd420f0 to your computer and use it in GitHub Desktop.
Save 3den/f7c55d0bcd9d809fdbe7f3da4fd420f0 to your computer and use it in GitHub Desktop.
#What’s the issue with the controller code below? How would you fix/improve it?
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