I have an app when users post album reviews called Pins. I created a comments model for other users to comment on the reviews. I\'m struggling getting the comments to say \"Post
You are assigning a User
instance to the username field for the Comment
. I assume that the username attribute is a string in the database. So if you want the name to appear in the comment then you need to assign it the name from the current user.
So:
@comment.username = current_user.name
If you already have an association between Comment
and User
then you could do:
@comment.user = current_user
<%= @comment.user.name %>
You save the username in
@comment.username = current_user
and show it with:
<%= comment.user.name %>
but it have to be
<%= comment.username %>