Last Updated: February 25, 2016
·
3.478K
· wildtangent

Rails 4 javascript_include_tag Gotcha

If you have a asset manifest file e.g.

= javascript_include_tag("admin/admin")
=> /app/assets/javascripts/admin/admin.js.coffee

The javascriptincludetag helper doesn't pick this up properly, instead giving you:

/javascripts/admin/admin.js

The correct way in Rails 4 appears to be

= javascript_include_tag("admin/application")

Rename your admin/admin.js.cofeee=> admin/application.js.coffee and it will correctly render

/assets/admin/application.js

Not sure why but it caught me out

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside