title: Uncaught ReferenceError: $ is not defined in Rails 5.2
body: <p>I'm building a rails application where I want to redirect the user to a <code>#show</code> action when they click on a index table's row.</p>
  
  <p>For this I'm trying to use Jquery in my coffeescript file. Here's the relevant code</p>
  
  <h2>index.html.erb:</h2>
  
  <pre><code>&lt;% @campaign.each do |campaign| %&gt;
      &lt;tr data-link="&lt;%= campaign_path(campaign) %&gt;"&gt;
          &lt;td&gt;&lt;%= campaign.campaign_name %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= campaign.start_date %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= campaign.created_at %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to "delete", campaign, class:"btn btn-default btn-xs", method: :delete, data: { confirm: "You sure?" } %&gt;&lt;/td&gt;
       &lt;/tr&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <h2>campaigns.coffee:</h2>
  
  <pre><code>$ -&gt;
    $("tr[data-link]").click -&gt;
      window.location.replace($(this).data("link"));
  </code></pre>
  
  <p>But once I run this I keep on seeing this error in the browser console: </p>
  
  <pre><code>Uncaught ReferenceError: $ is not defined
  </code></pre>
  
  <p>I have installed <code>jquery-rails</code> gem. Included it in my <code>application.js</code> file as well. When my application is rendered, I am seeing the Jquery script tag in the header also</p>
  
  <pre><code>&lt;script src="/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But still I'm seeing this error in the console</p>
  
  <pre><code>Uncaught ReferenceError: $ is not defined
  at campaigns.self-4617c47e06384e281aa2550caae08f3b4986441d2bfff9b6e3519f0a1e82f3d7.js?body=1:2
  at campaigns.self-4617c47e06384e281aa2550caae08f3b4986441d2bfff9b6e3519f0a1e82f3d7.js?body=1:8
  (anonymous) @ campaigns.self-4617c47e06384e281aa2550caae08f3b4986441d2bfff9b6e3519f0a1e82f3d7.js?body=1:2
  (anonymous) @ campaigns.self-4617c47e06384e281aa2550caae08f3b4986441d2bfff9b6e3519f0a1e82f3d7.js?body=1:8
  </code></pre>
  
  <p>Am I missing anything? Thanks for helping out.</p>