title: How to get Checkbox value in ruby on rails
body: <p>I want to get checkboxs values in order to set parameters of an http request to a restful API. I am new to web development and I am having troubles with ruby on rails 5.1 </p>
  
  <p>Basically, I have two views:
   - one where you can check/uncheck two checkboxs and then press a button which makes some API calls and send you to the second view.
   - the second is just for displaying the API informations.</p>
  
  <p>In the first view, I succeed to do the button that "makes" the API call, and the API informations are correctly displayed in the second. I now have trouble to add parameters, with the two checkboxs, to the request. My checkboxs are always returning me "nil" in params[].</p>
  
  <p>I referred to this section of the rails doc: <a href="https://guides.rubyonrails.org/form_helpers.html#helpers-for-generating-form-elements" rel="nofollow noreferrer">https://guides.rubyonrails.org/form_helpers.html#helpers-for-generating-form-elements</a>
  and to several other stackoverflow questions without understanding what I missed.</p>
  
  <p>here is the controller code: </p>
  
  <pre><code>class IndexController &lt; ApplicationController
    include HTTParty
  
    def button_state
    end
  
    def display_state
      require 'open-uri'
      require 'json'
  
      # this part is for checking my checkbox values, they are always nil
  
      @t1 =  params[:param_name1]
      @t2 =  params[:param_name2]
      @url_test = 'www.bkbahbqiv.com/tamere?test1=' &lt;&lt; @t1.to_s &lt;&lt; '&amp;test2=' &lt;&lt; @t2.to_s
  
      # other part related to the API calls
      ...
    end
  end
  </code></pre>
  
  <p>and here is my view code:</p>
  
  <pre><code>&lt;h1&gt;Check/Uncheck the boxes and click on the button to get results&lt;/h1&gt;
  &lt;div class="checkbox"&gt;
    &lt;td&gt;
    &lt;%= label_tag(:param_name1, "test1") %&gt;
    &lt;%= check_box_tag(:param_name1) %&gt;
    &lt;/td&gt;
  &lt;/div&gt;
  &lt;div class="checkbox"&gt;
    &lt;td&gt;
    &lt;%= label_tag(:param_name2, "test2") %&gt;
    &lt;%=  check_box_tag(:param_name2) %&gt;
    &lt;/td&gt;
  &lt;/div&gt;
  
  &lt;%= button_to "go to display_state", display_state_path, :method =&gt; :get %&gt;
  </code></pre>
  
  <p>I will just add that I don't want to store the checkbox values in a database.</p>
  
  <p>Thanks in advance for anyone helping me :)</p>