ruby-on-railscollection-select

Collection_select doesn't let me select when multiple => true


This is the template with multiple => true, but when i remove the multiple the selection tray works perfectly and takes in a single value. What i need is multiple options to be selected and to be stored in the confirer_string as a string.

The problem i'm encountering is that all the options are listed but they coudn't be selected though they can be clicked on.

new.html.erb

<%= form_with(model: @base, local: true) do |form| %>
  <%= form.label :description %>
  <%= form.text_field :description, id: :base_tbl_description %>

  <%= form.label :confirer_string %>
  <%= form.collection_select(:confirer_string, Confirmer.all , :position, :name,{ :prompt => "Please select" }, { :multiple => true } ) %>

  <%= form.submit %>
<% end %>

Is it a problem since i'm not using id's but integer fields. And one more thing :confirer_string is of type string.

There are two models, without any association between them. All i'm trying to do is get the list of options from the other model to be listed as option in the selection of primary model. Then the set of selected options will return their position, which will be stored in the confirer_string.

Thing is i cant select anything, not even one option when multiple is true.

UPDATE: i got the multiple select working again but i need to use ctrl+click to select mutliple entries. But the data is not storing, it is giving unpermitted error: conf_string


Solution

  • Just add the {attribute_name: []} in the strong params.