Saving related objects using has_many_through associations

This only saves the @person but not the @address. Shouldn’t it save
both?

 @person = Person.new(params[:person])
 @address = Address.new(params[:address])
 @person.address << @address
 @person.save

here is what I have:

class Person < ActiveRecord::Base
has_many :addressables
has_many :addresses, :through => :addressables
end

class Address < ActiveRecord::Base
has_many :addressables
has_many :people, :through => :addressables
end

class Addressable < ActiveRecord::Base
belongs_to :address
belongs_to :person
end

Any help would be appreciated,
Thanks
Serge

Hi Folks,

I just upgraded rails from 1.0.0 to 1.1.2. Suddenly, some of my “if
conditions” stopped working as expected. It seems as though
Rails/ActiveRecord now treats tinyint(1) columns as boolean instead of
integers (like v1.0.0).

I was just wondering if anybody else has experienced similar behavior?
If
so, is there a quick work-around that doesn’t involve me doing a search
and
replace and retesting my entire app?

TIA!

BTW, I am using mysql 5.0.16 and ruby 1.8.2

yeah ive been experiencing the same thing, anybody know how to get
around this or what the deal is?

Sergio B. wrote:

has_many :addressables
belongs_to :person
end

No, at present you have to explicitly create the Addressable object.

You may be better of using a has_and_belongs_to_many association,
since your Person<->Address association has no accessory attributes.


We develop, watch us RoR, in numbers too big to ignore.