You’re not receiving notifications from this thread.
How do I make comments show the user who created it?
I would think that i could do something like the code below but it's not working. How can i approach this so it can show the user who created the comment and other information about the user? I did follow the tutorial video on polymorphic associations if that helps.
- commentable.comments.each do |comment| .col-md-1 .image = image_tag comment.user.avatar.url(:medium) .col-md-11 .username = comment.user.username .created_at = comment.created_at.strftime("%b, %d") .comment-body %p = comment.body
You can do exactly what you've got here with the association on the comments. What's not working?
Ah hmm, I can't remember, did that episode include adding a
user_id column and
belongs_to :user association to the comments? I thought it did but it's been a while. :)
If you don't have that, you'll need to do that to reference the user and that should do the trick.