Attaching user to comment


#1

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


#2

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