# Attaching user to comment

**URL:** <https://www.ruby-forum.com/t/attaching-user-to-comment/104442>\
**Category:** Rails\
**Created:** [May 18, 2007, 1:35am UTC](https://www.ruby-forum.com/t/attaching-user-to-comment/104442 "2007-05-18T01:35:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 18, 2007, 1:35am UTC](https://www.ruby-forum.com/t/attaching-user-to-comment/104442/1 "2007-05-18T01:35:53Z")

</div>

How would I add a user name along with the form input? The user name  
is defined in application.rb as @current\_user

Below works 100% w/ adding the comment body/time but I wasnt sure how  
to add the user part

albums\_controller.rb

def comment  
@albums = Albums.find(params[:id])  
@albumscomment =  
Albums.find(params[:id]).comments.create(params[:comment])  
if request.post? and @albumscomment.save  
flash[:notice] = ‘comment submission succeeded!’  
redirect\_to :action =\> ‘show’, :permalink =\> @albums.permalink  
end  
end
