title: Working with javascript in a view in ruby on rails
body: <p>Alright guys, I am a ruby noobie here, and I find myself in the unfortunate situation where I am moving a project over from Django to Ruby on Rails. First things first, I am setting up my application.html.erb file, and I cannot seem to get the javascript working. The images and css are coming through, but not the javascript. There are javascript files within the assets directory and within the application.html.erb file. Neither are coming through.</p>
  
  <p>All of my images, css, and javascripts are located within their respective directories in app/assets/. </p>
  
  <p>My application.html.erb file head tag:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;HTML&gt;
  &lt;head&gt;
  &lt;!--[if lt IE 9]&gt;
  &lt;script src="http://html5shim.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  
  &lt;title&gt;The Atmosphere&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;link rel="shortcut icon" type="image/x-icon" href="/assets/atmosphere_favicon.png"&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/style.css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/profile.css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/advanced-slider-base.css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/small-round-button.css"&gt;
  &lt;link rel="stylesheet" media="all" href="/assets/hover.css"&gt;
  
  
  &lt;script type="text/javascript" src="/assets/jquery-1.7.2.min.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery-ui.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/scroll.min.js"&gt;&lt;/script&gt;
  &lt;!--&lt;script type="text/javascript" src="js/jquery.transition.min.js"&gt;&lt;/script&gt;--&gt;
  &lt;script type="text/javascript" src="/assets/jquery.touchSwipe.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.easing.1.3.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.advancedSlider.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/simplyScroll.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.marquee.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.pause.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.webticker.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/engine.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.jplayer.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/jquery.cookie.js"&gt;&lt;/script&gt;
  
  
  &lt;%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' =&gt; true %&gt;
  &lt;%= javascript_include_tag 'application', 'data-turbolinks-track' =&gt; true %&gt;
  &lt;%= csrf_meta_tags %&gt;
  
  
  &lt;!-- start soundmanager2 --&gt;
  &lt;!-- demo, make the fonts nicer etc. --&gt;
  
  
  &lt;!-- soundManager.useFlashBlock: related CSS --&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/flashblock.css" /&gt;
  
  &lt;!-- soundmanager required --&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/360player.css" /&gt;
  &lt;link rel="stylesheet" type="text/css" href="/assets/360player-visualization.css" /&gt;
  
  &lt;!-- sound manager Apache-licensed animation library --&gt;
  &lt;script type="text/javascript" src="/assets/berniecode-animator.js"&gt;&lt;/script&gt;
  
  &lt;!-- soundmanager core stuff --&gt;
  &lt;script type="text/javascript" src="/assets/soundmanager2.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/assets/360player.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  </code></pre>
  
  <p>The javascript in question within the application.html.erb file is between two script tags right before the body closing body tag. It's quite lengthy so I omitted it for the time being. </p>
  
  <p>I understand RoR has some conventions as far as the asset pipeline, and I'm assuming I'm missing some ruby syntax here, but I am used to just referencing the file paths and having everything working. Also, Is there some ruby syntax required within the view to make the javascript within the application.html.erb function? Right now it is just referenced as:</p>
  
  <pre><code>   &lt;body&gt;
       .
       .
        &lt;script&gt;
          .
          .
          .
  
        &lt;/script&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks guys! Any help is appreciated. </p>
  
  <p>My application.js file:</p>
  
  <pre><code>// This is a manifest file that'll be compiled into application.js, which will include all the files
  // listed below.
  //
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
  // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
  //
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  // compiled file.
  //
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
  // about supported directives.
  //
  //= require jquery
  //= require jquery_ujs
  //= require turbolinks
  //= require_tree .
  </code></pre>
  
  <p>application.css file:</p>
  
  <pre><code>/*
   * This is a manifest file that'll be compiled into application.css, which will include all the files
   * listed below.
   *
   * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
   * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
   *
   * You're free to add application-wide styles to this file and they'll appear at the bottom of the
   * compiled file so the styles you add here take precedence over styles defined in any styles
   * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
   * file per style scope.
   *
   *= require_tree .
   *= require_self
   */
  </code></pre>