Rails and the Asset Pipeline #
Let’s say you have a controller
users and a corresponding view. You also have a file
First, remove the line
//= require_tree . from
Next, you need to instruct Rails to include the users.js file for the users page. Do this by including the following line in the view/layout file for your users controller (embedded the view template language you use):
That’s it. Rails will now include your users.js script for the users page only.