title: How to add a js and coffee script file to the end of a specific page
body: <p>I am using morris.js to display a graph. The relevant js files are in <code>vendor/assets/javascripts</code></p>
  
  <p>I include them in application.js</p>
  
  <pre><code>//= require raphael
  //= require morris
  </code></pre>
  
  <p>The graph renders correctly when I am on the page that contains the morris graph element.</p>
  
  <p>Problem is that all the other pages with javascript don't work anymore (where there are no morris graph elements).</p>
  
  <p>I get this error:</p>
  
  <pre><code>Error: Graph container element not found
   throw new Error("Graph container element not found");
  </code></pre>
  
  <p>So how would I include the js files at the end of a certain page?</p>
  
  <p>I have tried to include the following at the end of the specific page:</p>
  
  <pre><code>&lt;%= javascript_include_tag "raphael.js" %&gt;
  &lt;%= javascript_include_tag "morris.js" %&gt;
  </code></pre>
  
  <p>But because the graph needs some coffee script located in employee.js.coffee:</p>
  
  <pre><code>jQuery -&gt;
  Morris.Line
   element: 'averages_chart'
   data: $('#averages_chart').data('averages')
   xkey: 'month'
   ykeys: ['average']
   labels: ['Average']
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>ReferenceError: Morris is not defined
  return Morris.Line({
  </code></pre>
  
  <p>I assume this is happening because its loading the coffee script at the beginning of the page before the <code>javascript_include_tag</code>?</p>
  
  <p>Please help</p>