Consider this situation: a model Person and a model State with a habtm
association between them. A person can be associated with one or more
States and a state can be associated with more than one person.
In a web form I have a SELECT input with all the states listed. I
create a new Person record and select three states and save. So far,
I then go back and edit the just-created record and de-select all the
states and press save. My intuition tells me that either I should get
a validation error or all the states should be dis-associated from the
person. However, what _does- happen is nothing: the record does not
change. The person still has the three states associated to him.
Looking at what get's PUT'ed I see that the SELECT's fieldname is not
passed to the browser when nothing is selected, so it appears that
Rails just assumes that if the input name does not appear in the PUT,
then it should ignore it. Is that true?
What is the recommended way to deal with this? Test for the absence of
the input field values, and if absent delete them explicitly?