similar to: Self-referential HABTM SQL mal-formed when updating record

Displaying 20 results from an estimated 5000 matches similar to: "Self-referential HABTM SQL mal-formed when updating record"

2006 May 28
7
Self-referential has_many :through relationship
Hi, I have a self-referential has_many :through relationship setup to track relationships between users. Basically relationships are modeled as a join table with an extra column ''relation''. create table relationships ( user_id integer unsigned not null, friend_id integer unsigned not null, relation char(1) not null, ) --- relations --- f = friend r = request to
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 |
2006 Mar 25
0
Self-Referential Many-To-Many relationships where the relationship itself has data.
Trying to model a bunch of users that have friends that are other users. clearly a job for has_and_belongs_to_many, but the trick is, they have ratings for their friends. I have gone through the Rails Recipes book, and it seems like I''m trying to combine the self-referential many-to-many recipe (12) and the many to many relationships where the relationship itself has data recipe (16). So
2006 May 02
0
Self-referential MtoM implementation
ok, guys i have followed the self referential recipe from the book it works perfect but now i have some doubts, at the end the model are modified to force the user beign added as a friend that add too who are adding him so how i can make that the full relationship doesn?t be complete until the friend beign added approves it(talking in the implementation of the code of course)? by the way,
2007 Jul 26
1
Bi-directional self-referential HABTM
Hi, I''m having a little trouble figuring out how to make a self- referential HABTM bi-directional. I have a Employee class. Each employee can have a couple of bosses, who are also employees. The employee class has the following HABTM: has_and_belongs_to_many :bosses, :class_name => "Employee", :join_table => "bosses_courses", :association_foreign_key =>
2006 Feb 21
7
Self-referencial habtm relationship
Heyo! I am setting up a self-referencial habtm relationship with the users of my app. I am using Chad Fowler''s "Rails Recipes" to get me started, and everything works great with the join table "people_friends". I add friends by doing somebody.friends << somebodyelse. However, with my app, there is an approval process so my join table has columns person_id,
2006 Aug 02
2
Self-Referential has_many :through
Hello all. I am trying to create a self-referential has_many :through. I used the following site as a guide http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through but it still doesn''t appear to be working. I have two models. Person and Relationship. A person has many contacts (Which is another person) through relationships class Person < ActiveRecord::Base
2006 Feb 25
0
self referential habtm using join tables
All: I have been working on making a self-referential habtm relationship that uses a join model because I want to store info about the relationship. I have been using two sections from Chad Fowler''s "Rails Recipes" as a guide, "Self-referential Many-to-Many Relationships" and "Many to Many Relationships Where the Relationship Itself has Data". So far I have
2007 Oct 22
1
self-referential habtm: why are my keys null?
I''m trying to set up a directional self-referential HABTM to represent an arbitrary semi-hierarchical structure; it works for any data prepopulated into the db, but when I try to create a new relationship, I just get NULLs in both key columns (or 0''s if I turn on the no-null constraint). Here are the migrations: class CreateNodes < ActiveRecord::Migration def self.up
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
Ok, David says on page 241 that sometimes a many-to-many relation with attributes are better implemented as an actual model instead of using HABTM. Well, I''ve got that situation and I can''t figure it out. All of the examples in the book have HABTM examples between 2 different tables, but I want to have a HABTM relation on 1 table with itself. (e.g., if I have a table Things,
2006 Mar 05
1
Help with Self-Referential HABTM
With the help of the Rails Recipes have got a self-referential HABTM relationship working, but I''m really struggling with getting a new entry from a form accepted. i should say here that the form is also submitting info for the join table too. So in my model I have: class Type < ActiveRecord::Base has_and_belongs_to_many :subtypes, :class_name => ''Type'',
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class. class Person < ActiveRecord::Base has_and_belongs_to_many :relatives, :class_name => ''Person'', :join_table => ''relatives'', :foreign_key => ''from_id'', :association_foreign_key => ''to_id'' has_and_belongs_to_many :brothers, :class_name =>
2006 Mar 31
6
Adding objects to a :through association
So I''m one of those nasty people building a self-referential habtm-like Association using the funky new :through stuff. This is about users having friends, so here''s my user.rb: class User < ActiveRecord::Base has_many :friendships, :foreign_key => ''user_id'' has_many :friends, :through => :friendships, :source => :friend end And here''s
2006 May 28
3
Association of table to itself
I''m curious what would be the best way to represent people and whether the person has someone marked as their friend. Here are my thoughts so far: People table - id - name Relationships table - person_id - friend_id Now my problem is I don''t know how to set up these associations (if this is even correct). Friend_id would be an id to someone else from the people table.
2006 Jan 06
2
Re: Some advice on DB modeling
I have more or less the same problem. I''m trying to build a system where users can enter their friends. But the solutions seems not to work for me. I used same sql: CREATE TABLE `friends` ( `user_id` int(11) NOT NULL default ''0'', `friend_id` int(11) NOT NULL default ''0'', KEY `user_id` (`user_id`), KEY `friend_id` (`friend_id`),
2006 Apr 05
4
Self-referential join creation/deletion and :through
Greetings. First, this example is just my way of exploring :through. It probably doesn''t need has_many :through, and could just use a standard HABTM association. Here''s the models: class CourseRequisite < ActiveRecord::Base belongs_to :requisite, :class_name => ''Course'', :foreign_key => ''requisite_id'' belongs_to :course,
2006 Nov 29
4
how do I model self-referential entities?
Hi all - I am having some trouble figuring out how to model self-referential entities in Rails. I have a "group" model, which can have 0 or more "group" objects or 0 or more "user" objects. I tried creating a subgroup table that has a parent_group_id and a child_group_id as foreign keys but can''t figure out how to create the mapping in my ruby model
2006 Apr 17
0
Pros/cons of doubling up in Self-Referential has_many via :through
Relative newbie so would welcome comments re structure of a self-referential relationship I''ve got. It''s started off similar to the Person HABTM friends in the Rails recipes books (working fine), but I needed to turn the join table into a full-blown model as I wanted to add attributes to it. Few tricky bits dealing with the new :through structure and understanding how :scope
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
2006 Jan 19
5
Multiple HABTM relationships with self ???
I need to have a table related to itself via a join table. Will HABTM support this? That is: class Recipe < ActiveRecord::Base has_and_belongs_to_many :recipes, :join_table => "recipes_recipes" end More importantly -- how does RoR support MULTIPLE self-joins? I.e., to relate the table to itself via multiple join tables. SFAIK, HABTM won''t support multiple