title: How do I submit more than one checkbox in an HTML form?
body: <p>This is a project for school, and so far I only know Ruby, Sinatra, HTML &amp; CSS. I've looked online but only came across PHP and Javascript insturctions (which I'm not supposed to use yet).</p>
  
  <p>I have a form for checkboxes, and although I can check off more than one, only one of the checkbox values gets posted. How do I get it so all of the checked off ones are passed?</p>
  
  <p>Also, 'abbreviation' comes out nil for each state. Am I doing this wrong in my form? And if anything it just uses ONE of the abbreviations and adds it to every state. Finally, how do I make it so the checkboxes remain checked for the states users have already added in the past? </p>
  
  <p>Here's some code:</p>
  
  <pre><code>&lt;form method="POST" action="/states"&gt;
  &lt;h3&gt;Northeast:&lt;/h3&gt; &lt;br&gt;
  &lt;input type="checkbox" name="state_name" value="Connecticut" name="abbreviation" value="CT"&gt; Connecticut&lt;br&gt;
  &lt;input type="checkbox" name="state_name" value="Deleware" name="abbreviation" value="DE"&gt; Deleware &lt;br&gt;
  &lt;input type="checkbox" name="state_name" value="Maine" name="abbreviation" value="ME"&gt; Maine&lt;br&gt;
  &lt;input type="checkbox" name="state_name" value="Maryland" name="abbreviation" value="MD"&gt; Maryland&lt;br&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>require 'pry'
  class StatesController &lt; ApplicationController
  
    get '/states' do
      if logged_in?
          @user = current_user
          @states = current_user.states
        erb :'states/states'
      else
        redirect to '/login'
      end
    end
  
  
    get '/states/new' do
      if logged_in?
        erb :'/states/create'
      else
        redirect to '/login'
      end
    end
  
    post '/states' do
        if logged_in? &amp;&amp; params[:state_name] != ""
          @state = State.create(:state_name =&gt; params[:state_name], :abbreviation =&gt; params[:abbreviation])
          # binding.pry
          @state.users &lt;&lt; current_user
            if @state.errors.any?
                "Error, try again"
            else
              redirect "/states"
            end
        else
          redirect to "/states/new"
        end
      end
  
  
    get '/states/:id' do
      if logged_in?
        @state = State.find_by_id(params[:id])
  
          if @state != nil
            erb :'/states/show'
          else
            redirect to '/states'
          end
      else
        redirect to '/login'
      end
    end
  
  
    get '/states/:id/edit' do
      if logged_in?
        @state = State.find_by_id(params[:id])
        if @state &amp;&amp; current_user
          erb :'states/edit'
        else
          redirect to '/states'
        end
      else
        redirect to '/login'
      end
    end
  
  
      patch '/states/:id' do
        @state = State.find_by_id(params[:id])
          if params[:state_name] != "" &amp;&amp; @state.update(:state_name =&gt; params[:state][:state_name])
            @state.update(:state_name =&gt; params[:state][:state_name])
            redirect to "/states/#{@state.id}"
          else
            redirect to "/states/#{@state.id}/edit"
          end
      end
  
      delete '/states/:id/delete' do
        if logged_in?
          @state = State.find_by_id(params[:id])
            if @state &amp;&amp; current_user
                @state.destroy
            end
          redirect to '/states'
        else
          redirect to '/login'
        end
    end
  end
  </code></pre>