Has_and_belongs_to_many - Access to Linkingtable


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


class Region < ActiveRecord::Base

has_and_belongs_to_many :countries


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

find country with id 12:

@country = Country.find(12)

then access it’s regions with: