title: Send data to controller through modal in rails 4
body: <p>I'm new in RoR and I'm stuck in this situation for a time now. I'm using a bootstrap modal with a table showing the users from database, and besides each a rage field. Need to send to controller the <code>user_id</code> and the value of the range.
  Something like this:</p>
  
  <pre><code>{0 {user_id1 : range_value1}, 1 {user_id2 : range_value2}}
  </code></pre>
  
  <p>Partial modal:</p>
  
  <pre><code>&lt;div class="modal-header"&gt;
     &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
     &lt;h3 id="modalLabel"&gt;Distribuir Estudos&lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="modal-body"&gt;
    &lt;table class="table table-bordered"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Integrante&lt;/th&gt;
          &lt;th&gt;Papel&lt;/th&gt;
          &lt;th&gt;Distribuição&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;% @users_protocols.each do |user_protocol| %&gt;
          &lt;tr&gt;
            &lt;td hidden&gt;&lt;%= hidden_field :user_id, value: user_protocol.id %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user_protocol.user.username %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user_protocol.role.name %&gt;&lt;/td&gt;
              &lt;td&gt;
                &amp;nbsp;
                &lt;span class="range-content"&gt;
                  &lt;input type="range" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="100"/&gt;
                  &amp;nbsp;&amp;nbsp;&lt;span&gt;100&lt;/span&gt;
                &lt;/span&gt;
                &lt;span&gt;%&lt;/span&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
        &lt;% end %&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
    &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Fechar&lt;/button&gt;
    &lt;%= link_to distribute_protocol_path, method: :put, :remote =&gt; true, class: 'btn btn-primary', id: 'btnDistribute' do %&gt;
        Distribuir
    &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Application.js</p>
  
  <pre><code>$('#btnDistribute').bind('click', function(e) {
          e.preventDefault();
          #Recover data from modal and send to controller
  });
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>def distribute_studies
      @users_protocols = Protocol.find(params[:id]).users_protocols.includes(:user).each do |user_protocol|
        puts user_protocol.id
        puts user_protocol.role.name
        puts user_protocol.user.username
      end
      respond_to do |format|
        format.html { render :back }
        format.json { head :no_content }
        format.js   { render :layout =&gt; false }
      end
    end
  
    def distribute
      #DO SOMETHING WITH DATA HERE
  
      redirect_to :back
    end
  </code></pre>