title: Correct way to make view updates in Rails
body: <p>So, I have a serious doubt for sometime. I see many people using ajax to make server requests when a update is needed in the front end. But what is the real difference between using ajax or for example using a link_to. For example I have this ajax code, which makes a server request to like a post:</p>
  <pre><code>$(function(){
      $(&quot;.pos-like&quot;).on(&quot;click&quot;, function(){
          var post_id = $(this).data(&quot;id&quot;)
          $.ajax({
              url: &quot;/post/like/&quot; + post_id,
              method: &quot;POST&quot;
          }).done(function(response){
              console.log(response)
  
          })
      })
  });
  </code></pre>
  <p>But in another case, it also works if I use a link_to in the view for that same request.</p>
  <pre><code>&lt;%= link_to like_path(post_id: post.id) do %&gt;
       &lt;i class=&quot;fa fa-heart fa-2x post-like&quot;&gt;&lt;/i&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>Then in the controller I just render a partial that just changes the color of the like button (using jquery).</p>
  <p>My question is, why do people normally use Ajax to make updates, when they can just use, for example, a link_to in the view. Are there any benefits when using ajax?</p>
  <p>Thanks!!</p>