title: How to make button change value on click in Ruby on Rails
body: <p>I'm having a lot of problems getting this to work, I don't quite understand how the view sends info to controller, so it can be manipulated.</p>
  
  <p>I have a button, which when clicked should change its value. Values changes between Yes / No.
  When the button is clicked it needs to change the corresponding value in the database, then in the view I already have the logic that decides button value.</p>
  
  <p>Here's some code, how I imagine it working...
  <code>show.html.erb</code> view</p>
  
  <pre><code>&lt;% status = @problem.status? 'No' : 'Yes' %&gt;
  &lt;%= link_to status, @problem, :class =&gt; 'btn btn-success' %&gt;
  </code></pre>
  
  <p>In my ProblemsController</p>
  
  <pre><code>def show
    @problem = Problem.find(params[:id])
  
    @problem.status ? @problem.status : (@problem.status == 'false')
  end
  
  def solve
  end
  </code></pre>
  
  <p>I'm not sure if I should change the database value in show method or create another one. The problem is that I don't know how to communicate from the view to the controller. How can I do this?</p>
  
  <p>I was considering adding <code>:data { solve: @problem.status }</code> to <code>link_to</code> tag, not sure if that would help though. So far I'm unable to enter solve method (I tried adding <code>:action =&gt; 'solve'</code> or <code>:action =&gt; '/problems/solve</code>' ), which didn't help. The following is something I just tried, but it doesn't work (doesn't go to solve action in ProblemsController).</p>
  
  <pre><code>&lt;%= link_to status, @problem, :controller =&gt; 'problems', :action =&gt; 'solve', :class =&gt; 'btn' %&gt;
  </code></pre>
  
  <p>I would definitely appreciate some help! Any ideas?</p>
  
  <p><strong>Edit</strong>: Added code for params in controller, which I had. Sorry I should've included it.</p>