From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

JavaScript

JavaScript - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

JavaScript

- [Instructor] In this movie we will learn to use asset pipeline to add JavaScript files to our application. There are four steps to adding a JavaScript file to asset pipeline and they're similar to the four steps that we just saw for adding style sheets. You first write your JavaScript file, then you make sure that it's included in your manifest, make sure that the manifest is included in the asset precompile list and then, once asset pipeline has those three things, it'll be able to assemble the JavaScript, ready for delivery to the browser. So the last step is just to go into the HTML and include the JavaScript there so that the page will load. If we're using asset pipeline, which you should be, JavaScript should be kept in app, assets, javascripts. If for some reason you wanted to have static JavaScript that did not use asset pipeline, you could also put that inside public, javascripts. The file name for JavaScripts should always end in dot js unless you're working with…

Contents