Storing the current_user in a string after they submit a comment
<%= f.text_field :commenter, :value => current_user, :readonly => "readonly" %>
So i can get the email in my comment view
<td><%= comment.commenter.email %></td>
but i’m getting
undefined method `email' for "#<User:0x7f26828>":String
Anyway to fix this?
You want to store whole object in html input? That shouldn’t work, because you strore only string
#<User:0x7f26828>. You should use relation between model:In form:
And add
commenter_idcolumn toCommentmodel. Then when you create just setcommenter_idand everything should work.