I have an app where I show posts by a current user (posts.current_user). I would like to show the most posts that have been most recently commented on by ordering by comment.date. It doesn't seem to want to do that...I keep getting:
PG::UndefinedTable: ERROR: missing FROM-clause entry for table "comment"
My Controller
def_index
@posts = current_user.posts.includes(:comment).order("comment.date ASC").includes(:image)
end
I have tried joins and includes an I can't seem to crack this. Thank you.
Try:
@posts = current_user.posts.joins(:comment).order("comments.date ASC").includes(:image)
Explanation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With