I used the acts_as_commentable in my app. But I find that, the user_id in comments table all equal0, I hv declaraed in the user model: has_many :comment, and I hv tried move the comment.rb in the model directory. but the user_id stays 0 whenever I add a comment. So do I need add one line when add a comment : comment.user_id current_user.id ? or can we solved in other approach? ( as I think this user_id should be added automatically and correctly by the plugin). Thanks for your help. -- infinit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rubynuby
2007-Dec-16 18:16 UTC
Re: acts_as_commentable, the user_id of comments always == 0
I think that is correct. user_id is the ID of the person making the comment, which can be zero if you don''t care about keeping track of who make what comments or allow anonymous comments. you have to set it manually. the has_many: comments association only allows you to do this User.find( 1).comments --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2007-Dec-16 22:50 UTC
Re: acts_as_commentable, the user_id of comments always == 0
It should be has_many :comments rubynuby already said this but I thought I would make it clearer. In the controller yes you would have to do something like: @comment = Comment.create!(params[:comment].merge(:user_id => current_user.id)) Rails does not do this automatically for you. On Dec 17, 2007 4:46 AM, rubynuby <dearluu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I think that is correct. user_id is the ID of the person making the > comment, which can be zero if you don''t care about keeping track of > who make what comments or allow anonymous comments. > > you have to set it manually. the has_many: comments association only > allows you to do this > > User.find( 1).comments > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---