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.
About JavaScript in Ruby on Rails - Ruby on Rails Tutorial
From the course: Ruby on Rails 6: Controllers and Views
About JavaScript in Ruby on Rails
- [Instructor] In this movie, we're going to learn about the several different ways that we can add JavaScript to our Ruby on Rails application. The first is that you can just add JavaScript directly to one of your templates. And that's a good choice if you just have a little bit of JavaScript and it's only going to be used on that one template. But as soon as we start having functions and functionality that needs to be reused, it makes sense to put that into a file and to load that file in the layout so that all of our pages can make use of it. One way to do that is just to simply write a JavaScript file to put it in the public directory and to load it. We saw the same thing with our style sheets and our images. But instead of just using plain JavaScript in a file, we can also make use of some features in Rails. The first is asset pipeline, which should now be familiar to you from both style sheets and images. We can use…
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
-
-
-