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

About JavaScript in Ruby on Rails - Ruby on Rails Tutorial

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

Start my 1-month free trial

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…

Contents