Note that there are some explanatory texts on larger screens.

plurals
  1. PONo more than one vaule being passed from a form in rails from multiple collection_select boxes
    text
    copied!<p>I have players and fixtures that are in a HABTM relationship. This works well however when I am trying to add more that one player to the fixture using the following in my create new fixture view: </p> <pre><code>&lt;li&gt;Player 1&lt;%= f.collection_select(:player_ids, Player.all, :id, :first_name, :prompt =&gt; true) %&gt;&lt;/li&gt; </code></pre> <p>Only one player is submitted. </p> <p><strong>Controller</strong></p> <p>I have this at the moment in my fixture Controller</p> <pre><code>def create @fixtures = Fixture.new(params[:fixture]) if @fixtures.save flash[:notice] = "Fixture Created" redirect_to(:action =&gt;'list') else render('new') end end </code></pre> <p><strong>View</strong> </p> <pre><code>&lt;%=form_for(@fixtures, :url =&gt; {:action =&gt;'create'}) do |f| %&gt; &lt;li&gt;Player 1&lt;%= f.collection_select(:player_ids, Player.all, :id, :first_name, :prompt =&gt; true) %&gt;&lt;/li&gt; &lt;li&gt;Player 2&lt;%= f.collection_select(:player_ids, Player.all, :id, :first_name, :prompt =&gt; true) %&gt;&lt;/li&gt; &lt;li&gt;Player 3&lt;%= f.collection_select(:player_ids, Player.all, :id, :first_name, :prompt =&gt; true) %&gt;&lt;/li&gt; </code></pre> <p>Could anyone help me out? I would prefer check boxes or a multiple select box where i could hold shift however I am finding these really hard to use. This I managed to submit values.</p> <p>Thanks</p> <p>If anyone needs any more informations on controllers or models I can edit these in to the quesiton</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload