You are missing foreign keys and / or have them in the wrong place. Remember that in the "child" model, a foreign key is required. This is the model that is. Thus, the address of Person has_one, the address is obsessed and must contain a foreign key that refers to Person.
- , . , , belongs_to a Person :
Address --> | address_id | person_id | street | suburb |
, .
Address --> | address_id | person_id | company_id | street | suburb |
:
$ rails generate model Address street:string suburb:string person_id:integer company_id:integer
$ rails g scaffold Person name:string
$ rails g scaffold Company name:string
. , Rails " ", belongs_to :person "" "" person_id Address.