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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 6: Controllers and Views
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Add style sheets to view templates7m 56s
-
(Locked)
Use static image assets5m 9s
-
(Locked)
Use images as CSS backgrounds4m 19s
-
(Locked)
About JavaScript in Ruby on Rails3m 50s
-
(Locked)
Manage JavaScript with Webpacker4m 2s
-
(Locked)
Configure asset pipeline for JavaScript5m 7s
-
(Locked)
Manage JavaScript with asset pipeline3m 37s
-
-
-