title: Unable to pass current_user.name as an attribute for comment
body: <p>Workaround for the below:</p>
  
  <pre><code>    &lt;%= f.label :Commenter %&gt;&lt;br&gt;
      &lt;%= f.text_field :commenter, :value =&gt; current_user.name %&gt;
  </code></pre>
  
  <p>This works for passing the username to the commenter attribute without having to type it in - with the addded bonus of being able to edit it if necessary!</p>
  
  <hr>
  
  <p>I am trying to make my website show the name of the user who created a comment. In order to do this, I would like the commenter (attribute of comment) to be assigned as current_user.name.</p>
  
  <p>comment has attributes commenter, body, and expdate.</p>
  
  <p>Is it possible to pass current_user.name to the comment.create method through the form?</p>
  
  <p>I've tried this:</p>
  
  <pre><code>&lt;div&gt;
      &lt;%= form_for([@project, @project.comments.build]) do |f| %&gt;
          &lt;br&gt;
  
          **&lt;%= @commenter = current_user.name %&gt;**
  
          &lt;%= f.label :Comment %&gt;&lt;br&gt;
          &lt;%= f.text_area :body %&gt;
          &lt;br&gt;
          &lt;%= f.label :'Expected Date' %&gt;&lt;br&gt;
          &lt;%= f.date_select :expdate %&gt;
          &lt;br&gt;
          &lt;br&gt;
          &lt;%= f.submit %&gt;
      &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Where I assigned the commenter attribute to be current_user. Does this not pass that to the create method?</p>
  
  <p>I have also tried assigning it in the comments_controller like this:</p>
  
  <pre><code>def create
      **@comment.commenter = current_user.name**
      @project = Project.find(params[:project_id])
      @comment = @project.comments.create(comment_params)
      redirect_to project_path(@project)
  end
  </code></pre>
  
  <p>But I get an error complaining that commenter is not a defined method.</p>
  
  <p>Both of the methods I tried don't allow me to create a comment, does anyone have any ideas of how I might do this?
  Many thanks in advance!</p>