# Associating has\_many through on create

**URL:** <https://www.ruby-forum.com/t/associating-has-many-through-on-create/134351>\
**Category:** Rails\
**Created:** [April 10, 2008, 1:39am UTC](https://www.ruby-forum.com/t/associating-has-many-through-on-create/134351 "2008-04-10T01:39:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [April 10, 2008, 1:39am UTC](https://www.ruby-forum.com/t/associating-has-many-through-on-create/134351/1 "2008-04-10T01:39:33Z")

</div>

when my models had a HABTM relationship, i got the cool method that  
assigns relational items when creating a new record. the simple  
example that i can think of would be a habtm between posts and  
categories.

if i’m creating a new post, i can just use the category\_ids= method  
and everything works. now that i’m using HMT, i don’t have that nice  
method anymore. what’s the best way of associating categories to posts  
on create.
