habtm only saving one record

I use habtm and a mulitline select to select which publications a journalist works on.

class Journalist < ActiveRecord::Base    has_and_belongs_to_many :publications end

AND

class Publication < ActiveRecord::Base    has_and_belongs_to_many :journalists end

When I make changes in the select, only the first selected item gets a record in the habtm table:

From the log: Parameters: {"commit"=>"Update Journalist", "journalist"=>{"publication_ids"=>["3,5,4,1"], }, "authenticity_token"=>"a7Lws3tWNS+FczclJEYuu4EusVINUsuy6rwLVagMdLk=", "utf8"=>"✓", "id"=>"7"}

Then some rows down(!?): INSERT INTO "journalists_publications" ("publication_id", "journalist_id") VALUES (3, 7)

So, what happened to (5,7), (4,7) and (1,7)???

Migration:     def self.up       create_table :journalists_publications, :id => false do |t|         t.references :journalist, :publication       end       add_index :journalists_publications, :journalist_id       add_index :journalists_publications, :publication_id     end

Form: <%= form_for(@publication, :remote => true) do |f| %>    <%= f.collection_select(:journalist_ids, Journalist.limit(20).order('id'), :id, :name, {}, {:multiple => true}) %> <% end %>

Controller: @journalist = Journalist.find(params[:id]) if @journalist.update_attributes(params[:journalist]) ...

Does anyone have a clue? Rails 3.0.5

This gets even stranger.

The problem is that the parameter from the mulitline collection_select is an array with ONE element! The element is a string "3,5,4,1". To update the habtm I need an array of four integer elements [3,5,4,1]

How can this happen???

:frowning: jeb