liftedmedia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-17 23:35 UTC
Attaching user to comment
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
liftedmedia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-17 23:37 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---