I have a Post model and a Comment model; Post has_many comments, and Comment belongs_to Post
In my Post controller, I want to select a random comment, and display the comment's date. I'm a little confused how to query this from my Post controller.
In my Post Controller, I have:
@posts = Post.where(:public_flag => true).order('created_at DESC')
I'm a little stuck after this. Should I be getting the comments from the view? Or doing another query from the controller to get the comments? Then, how do I just select a random comment once I get all the comments?
Thanks in advance! Really appreciate your help.