title: Increment variable by 1 and save to db with button_to in Ruby on Rails
body: <p>Simple rails question (new to the community) and am having some trouble getting the following to work properly. Could somebody point out what I may be doing incorrectly?</p>
  <p>I have a model called <code>option</code> that stores rows of options, and has a column, <code>vote_count</code>, that needs incremented by 1 every time the button below is clicked.</p>
  <p>Here is my code:</p>
  <p>Routes is below, here I want to use the vote route for the controller and button.</p>
  <pre><code>Rails.application.routes.draw do
      post '/vote', to: 'responds#vote', as: 'vote'
      resources :polls, except: %i( show new ) do
      resources :options, only: %i( create update destroy )
      resource :respond
      resource :visualization, only: %i( show )
    end
  
    root &quot;polls#index&quot;
  end
  
  </code></pre>
  <p>Responds Controller</p>
  <pre><code>class RespondsController &lt; ApplicationController
  
      def vote
          @option = option.find(1)
          @option.vote_count += 1
          @option.save
      end
  
    before_action :set_poll
  
      private
  
          def set_poll
              @poll = Poll.find(params[:poll_id])
          end
  
  end
  </code></pre>
  <p>Here is the HTML</p>
  <pre><code>&lt;%= stylesheet_link_tag 'application.css' %&gt;
  &lt;div class='flex items-center'&gt;
    &lt;div class='w-full'&gt;
      &lt;div class='text-gray-700 text-3xl'&gt;
        &lt;%= option.title %&gt;
        &lt;div class=&quot;vote-count2&quot;&gt;
          &lt;%= button_to &quot;Click To Vote!&quot;, vote_path, class: 'vote_count' %&gt;
        &lt;/div&gt;
              Total Vote Count: &lt;%= option.vote_count %&gt; |
              Option ID: &lt;%= option.id %&gt;
  
        &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  </code></pre>
  <p>Everything is rendering properly, no errors, I am just unsure how to get the votes to increment and update in the db properly (sqlite).</p>