On Jul 20, 11:00 am, Eduard Martini <[email protected]> wrote:
> in authors model:
>
> has_one: city_of_birth, :table => cities
> has_one :city_of_death, :table => cities
>
> in authors table:
> city_of_birth_id, city_of_death_id
>
> author instance:
>
> @author.city_of_birth
> @author.city_of_death
>

You've got those backwards - they should both be belongs_to, as the
foreign key lives in the authors table not the cities table.

I'd second the question about why these can't just be plain text
fields; there are a huge number of cases where a person could live in
exactly the same house their entire life and still manage to be born
in one city but die in another. For that matter, be born in one
*country* and die in another without leaving the house...

Your cities table is likely to be full of semi-duplicate entries that
vary with time - as a concrete example: I live in Columbus, Ohio.
Before 1812, there was no such city. Well after the city's founding,
additional areas (Franklinton, for instance) that used to be
independent cities were annexed into Columbus.

Bonus points if you can figure out how to represent authors whose
birthplace is not a matter of settled historical fact (primarily an
issue with some pre-20th century authors)...

--Matt Jones

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to