text_fields and habtm

how can i set the text_fields to put data into a model with habtm
bindings?

Example:

model1 has_and_belongs_to_many :model2

how can i insert data into the references of model2 into model1?