# habtm relation, cannot populate join table

**URL:** <https://discuss.rubyonrails.org/t/habtm-relation-cannot-populate-join-table/51079>\
**Category:** rubyonrails-talk\
**Created:** [April 21, 2010, 12:09pm UTC](https://discuss.rubyonrails.org/t/habtm-relation-cannot-populate-join-table/51079 "2010-04-21T12:09:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [April 21, 2010, 12:09pm UTC](https://discuss.rubyonrails.org/t/habtm-relation-cannot-populate-join-table/51079/1 "2010-04-21T12:09:00Z")

</div>

Hai friends, I hav two models related with habtm

class User \< ActiveRecord::Base &nbsp;&nbsp;has\_and\_belongs\_to\_many :station, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:join\_table =\> "stations\_users", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:foreign\_key =\> "user\_id", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:association\_foreign\_key =\> "station\_id"

class Station \< ActiveRecord::Base &nbsp;&nbsp;has\_and\_belongs\_to\_many :user end

When i create a new user its user\_id and the station \_id is not inserted into the "stations\_users" table.I hav used scaffolding 4 creating these two models.How can i insert the fields for the join table also when a user is created? Can any one help me?

Thanks and regards, Veena
