Drop down and has_and_belongs_to_many

I have a has_and_belongs_to_many relationship between categories and
links

How I add a dropdown to select categories in links/new and links/edit
actions?

I suspect I need another select field in partial _form for this, but I
don’t know exactly what and how to use.

Thanks