# Saving related objects using has\_many\_through associations

**URL:** <https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234>\
**Category:** Rails\
**Created:** [April 8, 2006, 8:28am UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234 "2006-04-08T08:28:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbayona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@sbayona](https://www.ruby-forum.com/u/sbayona)\
**Post date:** [April 8, 2006, 8:28am UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234/1 "2006-04-08T08:28:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sbayona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@sbayona](https://www.ruby-forum.com/u/sbayona)\
**Post date:** [April 10, 2006, 10:30pm UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234/2 "2006-04-10T22:30:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![sbayona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@sbayona](https://www.ruby-forum.com/u/sbayona)\
**Post date:** [April 10, 2006, 10:45pm UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234/3 "2006-04-10T22:45:36Z")

</div>

BTW, I am using mysql 5.0.16 and ruby 1.8.2

---

<div class="post-metadata">

**Author:** ![sbayona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@sbayona](https://www.ruby-forum.com/u/sbayona)\
**Post date:** [October 10, 2006, 7:07am UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234/4 "2006-10-10T07:07:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sbayona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@sbayona](https://www.ruby-forum.com/u/sbayona)\
**Post date:** [April 10, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/saving-related-objects-using-has-many-through-associations/57234/5 "2006-04-10T15:04:22Z")

</div>

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.
