Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class CommentsController < ApplicationController
# I assumed the usual naming for models and foreign columns
def users_comments
# I don't like where( post_id: Post.all ) but if table comments
# contains deleted posts comments or even NULLs than we need to keep it this way
@user_comments = Comment.where( post_id: Post.all )
.where(author_id: Author.where( username: params[:username]) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment