Simple tables question


#1

Sorry for this rudimentary question… I’ve been following Pragprog’s
rails book, and somehow I’m still missing something basic:

I need to make a table (class) where one of the columns’ (attributes’)
type is an array of objects of another class. In other words, I need to
know how to implement a phone-book list, where you can click on the name
of the entry and be taken to that person’s, say, bank info.

Does anybody know of any guides that might walk me through this, or be
able to give me a rough picture of what needs to be done so I can figure
it out myself?

Thanks.


#2

Does anybody know of any guides that might walk me through this, or be
able to give me a rough picture of what needs to be done so I can
figure
it out myself?

I think you want two separate models… where one has many of the other.

That is…

class Contact << AR…
has_many :phone_numbers
end

class PhoneNumber << AR…
belongs_to :contact
end

Your sql table “phone_numbers” would then have a “contact_id” field.

-philip