The problem is that Select2 sends back a string list of items, e.g. "thing_ids" => "1,2,3"
. What I do when using Select2 in this way is to create accessor methods for thing_tokens
and thing_tokens=
, which look something like this:
def thing_tokens
thing_ids.join(",")
end
def thing_tokens=(token_string)
self.thing_ids = token_string.split(",")
end
Then, in your form, you'll make it be an input for :thing_tokens
instead of thing_ids
. If you're using Rails 4, make sure you also permit :thing_tokens
in your controller.