From the course: Ruby on Rails 6: Controllers and Views

Unlock the full course today

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

Manage JavaScript with asset pipeline

Manage JavaScript with asset pipeline - Ruby on Rails Tutorial

From the course: Ruby on Rails 6: Controllers and Views

Start my 1-month free trial

Manage JavaScript with asset pipeline

- Once you've read enabled JavaScript to work with Asset Pipeline, then we're ready to learn how to manage it. The process is very similar to what we saw with Style Sheets. The asset precompile list needs to include the manifest, the manifest should include the JavaScript files that we want it to precompile, and then the JavaScript file would contain various functions. The JavaScript include tag then loads the compiled JavaScript into the HTML page. As we've already seen, we're going to be putting these into the app assets JavaScripts directory, and the file name should end in .js for all of them. Like Style Sheets, Rails also gives us a helper tag for this. It is javascript_include_tag, and then the name of the manifest that we want to include, all of the compiled JavaScripts that have been put together. Notice that it's javascript_include_tag. With Style Sheets, it was stylesheet_link_tag, and when we were…

Contents