Field select duplicating with Chosen-Rails and relationship has Many through

Asked

Viewed 75 times

0

Personal talk,

I have a GROUP_TV table and it relates to the City table through has Many through.

In the _from.html.erb view of GROUP_TV, I have a collection_select to select as many cities as I want. This works perfectly.

The problem happens when I add Chosen’s Gem and configure it to display in that field, it even works, but on the editing page it duplicates, for example:

If in the NEW action I selected the cities: Americana and Barueri and saved, in the EDIT action appear 2 SELECT fields with the same values in each, see the print below:

Print do erro

How can I fix this?

Follow the select code

<%= f.collection_select(:city_ids, City.all, :id, :name, {prompt: "Selecione as cidades"}, {:multiple => true, class: "select-chosen"}) %>
  • 1

    If you put 3 cities, appear 3 selects or only 2?

1 answer

0

I don’t know if I remember your problem, but this has happened to me and I solved it in params.permit. using my example:id

 params.require(:project).permit(:name, :description,tasks_attributes: [:id, :description, :done, :melhorar, :_destroy])

that doubt is from six months ago, but someone may have the same problem

Browser other questions tagged

You are not signed in. Login or sign up in order to post.