HABTM and select form helper

I am very confused about HABTM and a form select statement that I need
to
implement.

I have two objects - Person which has the following fields:
id, firstname, lastname, email

Category which has the following fields:
id, name

A person HABTM categories and also the reverse. I have setup the join
table
using a migration. All that went well.

Two questions - If I want to edit a person, how do I use some kind of
form
helper (collection_select?) to correctly create a multiple select
statement
that has persons categories already selected? I can’t figure out that
syntax at all.

And, how do I get the results of that select back into the Person
object?
In a controller, if I do this:
person.attributes = params[:person]
then the person object is expecting category objects, but of course it
is
getting strings from the select, so it doesn’t work.

I appreciate any help…

Shelby

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs