Hello, i just don''t get how to refer and edit the automaticly generated table by has_many_belongs_to_many (n:m) relation. Here are my basics (shortend): class Country < ActiveRecord::Base has_and_belongs_to_many :regions end class Region < ActiveRecord::Base has_and_belongs_to_many :countries end So now rails creates a new table countries_regions in the db. how can i access the information out of this table. E.g. i want to know the region of a specific country (by id). Lets say the country belongs to 2 regions (Europe, Asia). thanks rob -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2007-Nov-26 12:49 UTC
Re: has_and_belongs_to_many - Access to Linkingtable
find country with id 12: @country = Country.find(12) then access it''s regions with: @country.regions -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---