Gumby
(Gumby)
1
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;
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
11175
(-- --)
3
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.