Select duplicate field with chosen-rails and relationship has many through

0

Personal speech,

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

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

The problem happens when I add the chosen gem and set it to display in that field, it even works, but in the editing page it doubles, for example:

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

HowcanIresolvethis?

Followtheselectcode

<%=f.collection_select(:city_ids,City.all,:id,:name,{prompt:"Selecione as cidades"}, {:multiple => true, class: "select-chosen"}) %>
    
asked by anonymous 06.05.2016 / 22:23

1 answer

0

I do not know if it solves your problem, but this already 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])

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

    
03.11.2016 / 17:52