Forum: Ruby on Rails Attaching user to comment

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2007-05-18 03:37
(Received via mailing list)
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
Amos K. (Guest)
on 2007-05-18 17:22
(Received via mailing list)
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 topic is locked and can not be replied to.