similar to: Self-referential MtoM implementation

Displaying 20 results from an estimated 300 matches similar to: "Self-referential MtoM implementation"

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 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 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 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
2007 Jul 21
3
unable to get "has_many :after_add" to work - need help
Can someone tell me what I''m doing wrong? I''ve spent way too much time on this -------------------------------------------------------------------------------------- class Picture < ActiveRecord::Base has_many :ratings, :after_add => :increment_rating, :after_remove => :decrement_rating def increment_members(rating) self.rating += rating.amount save!
2010 Jul 12
1
How to turn :before_add exceptions into validation errors
As per http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Possible callbacks are: before_add, after_add, before_remove and after_remove. Should any of the before_add callbacks throw an exception, the object does not get added to the collection. Same with the before_remove callbacks; if an exception is thrown the object doesn‘t get removed. However, when the add
2008 Jan 23
1
Self-referential HABTM SQL mal-formed when updating record
Guys, Anyone ever had this kind of problem with ActiveScaffold? Cheers, Sazima ------------------------------------------------------------------------------------------------ What steps will reproduce the problem? 1. Create self-referential HABTM application (like the common "user has friends" example) 2. Try to add more than 1 friend to a given user using ActiveScaffold. What is
2006 Aug 31
1
SOAP MTOM
Any thoughts on extending ActionWebService to handle MTOM? http://www.w3.org/TR/soap12-mtom basically, this allows some flexibility when it comes to base64 encode/decode on the message, binary attachments can pass without being encoded... am I on my own here? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups
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 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 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 28
1
Advice on Optimization, and where to put what?
In my last post I was asking how I could check for the existance of a record before inserting a new one and this was the helper method that I was using to do this: def already_friend_of?(friend) begin self.friends.find(friend.id) true rescue false end end I was told that this is not very efficient, as it hits the db every time I call it. I completely agree and would like to
2013 May 30
0
Import friends
Hi friends, I need send invitation to my facebook friends. i can import all my facebook friends. but when i send a message to particular user this message send all my friends. how can i solved it. Please help me. this is my code def facebook_invite friend_id= params[:mail] logger.debug(''CURRENT'') logger.debug(
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 Oct 31
5
conditional boost? friends to come up at top of search...
Hey guys, im trying to get my friends to come up at the top of the act as ferret search. I would query the whole result set first, then move my friends to the top, but the thing is, Im paginating my results and use the offset and limit parameters in the multi_search() function. Anyone know how to do this? Thanks in advance... -- Posted via http://www.ruby-forum.com/.
2006 Nov 10
1
Harris picking up before extension
Hi there! I'm setting up a connection between Asterisk ver. 1.2.13 and a Harris 20-20 PBX. More less everything went fine, but the problem I have now is when dialing to the Harris PBX, it seems to pick up my call as soon as it reaches it. For example if from the Asterisk outgoing folder I dial an extension, say 100, and play a prompt as soon as it is picked up, the promt is beign played as
2006 Apr 03
1
has_many :trough with 2x the same table
I have a site where Users can become Friends with other Users. I used to do this with a habtm, but of course I want to stay up-to-date and convert this to a has_many :trough. Unfortunately I can''t get it to work.. the documentation on this feature is a bit sparse at the moment. This is my old habtm: has_and_belongs_to_many :friends, :join_table => ''user_friends'',
2006 Apr 19
1
Anatomy of an application in rails
Ok guys, after doing many tutorial arond the web i realize that im not going to learn rails well until a made my own app, so i defined what i want and structured in a way that hope you can understand, maybe we can help each other and define a good starting base(models and relationships) that can be helpful for all of us. Its a little(i think cms), it will consist of basically 4 sections:
2006 Jun 23
0
adding action after a belongs_to assignment
What is the best way to add action after a belongs_to assignment? (Just like ''after_add'' in has_many assignment). I see that there is no callbacks for belongs_to. I have tried overriding parent= : alias :parent_before_mod= :parent= def parent=(the_parent) parent_before_mod = the_parent if save # my actions here end end but when I tried to assign parent, parent_id
2010 May 24
3
ActionController::DoubleRenderError
def dispfriends @myfriend=[] @myfriendlogin = [] i=0 @currentgroup = Group.find_by_id(params[:groupid]) puts @currentgroup.id @currentfriends= GroupFriend.find_all_by_user_id_and_group_id(current_user.id, @currentgroup.id) for n in @currentfriends @myfriend=n.friend_id @myusers = User.find_by_id(@myfriend) @myfriendlogin[i]=@myusers.login puts @myfriendlogin[i] i=i+1 respond_to do