I am very new to Rails and I want to create a Person model that has one Address and a Company Model that has one Address and one Person.
Here is what I've done so far
$ rails generate model Address street:string suburb:string
$ rails g scaffold Person name:string address:references
$ rails g scaffold Company name:string person:references address:references
class Address < ActiveRecord::Base
belongs_to :person
belongs_to :company
end
class Person < ActiveRecord::Base
has_one :address
end
class Company < ActiveRecord::Base
has_one :person
has_one :address
end
Obviously I am missing something. Does Address need a polymorphic association?
I am pretty lost, so any guidance would be appreciated.
Cheers