Created
November 30, 2017 22:23
-
-
Save 3den/f7c55d0bcd9d809fdbe7f3da4fd420f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#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