if I want to allow users to rate each other.. would this be the way to do it? rating model: belongs_to :users foriegn_key=>''rated_user_id'' belongs_to :users foriegn_key=>''rating_user_id'' user model: has_many :rating foriegn_key=>''rated_user_id'' has_many :rating foriegn_key=>''rating_user_id'' rating_user table int rating_user_id; int rated_user_id; Ratings table int rating; int rated_user_id; int rating_user_id; --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 9, 9:48 am, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> if I want to allow users to rate each other.. would this be the way > to do it? > > rating model: > > belongs_to :users foriegn_key=>''rated_user_id'' > belongs_to :users foriegn_key=>''rating_user_id'' > > user model: > > has_many :rating foriegn_key=>''rated_user_id'' > has_many :rating foriegn_key=>''rating_user_id''Looks good to me, assuming one rating per user-user combination (i.e., can''t rate the same guy twice and still save the old rating). ///ark --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No, I think you need something like this (and be sure to spell "foreign_key" right ;): Rating model: belongs_to :rating_user, :class_name => "User", :foreign_key => "rating_user_id" belongs_to :rated_user, :class_name => "User", :foreign_key => "rated_user_id" User model: has_many :received_ratings, :class_name => "Rating", :foreign_key => "rated_user_id" has_many :given_ratings, :class_name => "Rating", :foreign_key => "rating_user_id" I think you have an extra table... you shouldn''t need rating_user. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---