Attaching user to comment

How would I attach as user to the form input being added into the db?
User name is defined as @current_user in application.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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs