Hi! The next question: I have 2 tables: 1) persons - where some people info places (e.g. name, second name, birth date et.c.) 2) persons_relationships - here app would write relationships between persons. Here is structure: id|from|to|type, where from is the one person id, to - second person id, type is kind of relations between them (friend-friend, parent-child, husband-wife et.c.) So, when I prefer to find all person relationships (@person.relationships) - in model I can create query only with :from or only :to fields. Eg.: if I create association @person.id with :from field, but in record in relationships table client id would place in :to field, then this record will be removed from @person.relationships. How I can prevent this error? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bump! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Supply the associations you have set in your model files and then supply the query you are using or having trouble with. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 29 August 2011 16:09, Misha Ognev <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi! The next question: > > I have 2 tables: > 1) persons - where some people info places (e.g. name, second name, > birth date et.c.) > 2) persons_relationships - here app would write relationships between > persons. Here is structure: > id|from|to|type, where from is the one person id, to - second person id, > type is kind of relations between them (friend-friend, parent-child, > husband-wife et.c.) > > So, when I prefer to find all person relationships > (@person.relationships) - in model I can create query only with :from or > only :to fields. Eg.: if I create association @person.id with :from > field, but in record in relationships table client id would place in :to > field, then this record will be removed from @person.relationships. How > I can prevent this error?I don''t understand exactly what you are saying, but note that if you have a model Person then the table should be called people not persons, assuming you have not changed the default pluralization. -- Colin https://plus.google.com/111605230843729345543/ -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.