I have this form:
<form accept-charset="UTF-8" action="/contracts/<%= params[:id] %>/addConsultants" method="POST" id="updateConsultants"> <div style="margin:0;padding:0;display:inline"> <input name="utf8" type="hidden" value="✓"> <input name="authenticity_token" type="hidden" value="<%= session[:_csrf_token] %>"> </div> <div class="consultant_selector"> <h2>Consultants</h2> <select name="consultants_available" size="10" multiple> <% @users.each do |u| %> <option value="<%= u[:id_user] %>"><%= u[:name] %></option> <% end %> </select> <ul> <li class="triangle_right" id="add_consultant"></li> <li class="triangle_left" id="remove_consultant"></li> </ul> <select name="consultants_selected" size="10" multiple> </select> </div> <div> <input type="submit" value="Mettre à jour" /> </div> </form>
And in my controller:
def add_consultants @contract = Contract.find(params[:id]) @consultants = params[:consultants_selected]; puts "------ Consultants: #{@consultants}" redirect_to contract_path end
The idea is that I can select the names from the first selection, move them to the second by clicking on the triangle, and then submit the form to assign these names to the contract. However, when I do this, the puts call only displays one of the 3 IDs that I have in the second select (all three of them have the selected attribute for true ). How to get multiple values?
ruby-on-rails forms
Damien T Dec 18 '13 at 9:50 a.m. 2013-12-18 09:50
source share