When the join model is created

In a has_many :through association the join model is automatically
But…how the parameters are passed to the model?
For example, if I have
has_many :models
has_many :models2, through => :models


has_many :models
has_many :model1, through => :models

The join model is Model.

and I create a new Model1, how params model1_id and model2_id are
passed to model Model?

I want to manage them in a after_save callback of the join model.
How can I do that?

When you will create the object of model1 at that time you have to
just assign the related records of models2.

For eg.

model1 = Model1.new(…)
model1.model2_ids = [selected object id of model2]

It automatically handles the association between currently created
of model1 and model2. Then after look at your intermediate table and it
will show the related ids of both the tables.