Association dows not grt foreign key

I have a 1 to 1 relationship using a similar example as below
(has_one, belongs_to)

but when I do the save, the foreign key of the child object is not set
to the id of the parent object in the relation ship

any ideas?



class Person < ActiveRecord::Base
has_one :address
validates_presence_of :email

class Address < ActiveRecord::Base
belongs_to :person

person = = “[email protected]
address = = “Austin”
person.address = address
person2 = Person.find_by_email “[email protected]
=> “Austin”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs