title: How to use Javascript in Ruby on Rails?
body: <p>I think I'm fundamentally misunderstanding how to implement Javascript in my rails app. My understanding was that you throw your Javascript into your <code>application.js</code> file and then you can reference elements in your DOM using <code>jQuery</code> in order to make an interactive web page.</p>
  
  <p>I just checked through all of my code, and it looks clean (posted below in case I'm wrong). My thought is that I may be putting my Javascript in the wrong place, or I'm missing a dependency somewhere? I found other posts to be mostly unhelpful for me. How do I merge Javascript into my app?</p>
  
  <p><strong>application.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>function main() {
    $('.answers-box').hide();
    $('.qaa-box').on('click', function() {
      $(this).next().slideToggle(400);
    });
  }
  $(document).ready(main());
  </code></pre>
  
  <p><strong>page.html.erb</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="qaa-box"&gt;
    &lt;h4&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit&lt;/h4&gt;
    &lt;p class="answers-box"&gt;
      Lorem ipsum dolor sit amet, consectetur adipiscing elit
    &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>