Displaying 3 results from an estimated 3 matches for "friends_people".
2006 Aug 15
2
How to access attribute in a self-referential many-to-many relationship
Hello List,
I created a self-referential many-to-many relationship (as described
in the book Rails recipe #18), where I have a model that has
many-to-many relationships with itself. In this case, it''s person who
can become friends. The join table looks like this:
mysql> select * from friends_people;
+-----------+-----------+-----------+
| person_id | friend_id | confirmed |
+-----------+-----------+-----------+
| 1 | 2 | NULL |
| 2 | 1 | NULL |
| 1 | 3 | NULL |
| 3 | 1 | NULL |
and the people table is
mysql&g...
2006 May 02
0
Self-referential MtoM implementation
...end beign added approves it(talking in the
implementation of the code of course)?
by the way, here is the code:
class AddPeopleAndTheirFriendsRelationship < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.column "name", :string
end
create_table :friends_people do |t|
t.column "person_id", :integer
t.column "friend_id", :integer
end
end
def self.down
drop_table :people
drop_table :friends_people
end
end
class Person < ActiveRecord::Base
has_and_belongs_to_many :friends,
:class_name => "Pe...
2006 Apr 20
2
table that have many-to-may relationship to itself
In a social netowrk data model, users belongs other users, and can have
many friends as users, so it is a many to many relatioship.
the class definition could be
class User < ApplicationController
has_mang_ang_belongs_to users
But how it looks like in the mysql database tables in a "joined" users
table.
The question really is: what is the table looks like when a model has