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.
Abed21abff74d51f99d8ae6ad8e5a3e9?d=identicon&s=25 liftedmedia@gmail.com (Guest)
on 2007-05-18 01: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
F04aeb28129f653b207e8b5d92706096?d=identicon&s=25 Amos King (Guest)
on 2007-05-18 15: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.