Some Guy
Some Guy

Reputation: 13568

How can Rails 5 Javascript use vendor assets?

I have a new Rails 5 app and am trying to use some vendor assets in my main Javascript file:

//= require json2.min.js

And the file json2.min.js is in the /vendor/javascripts/ directory.

However I get this error:

couldn't find file 'json2.min.js' with type 'application/javascript'

I am reading the documentation but cannot figure out why this doesn't just work?

Upvotes: 0

Views: 1360

Answers (1)

mu is too short
mu is too short

Reputation: 434665

My stock-ish app/assets/javascripts/application.js says:

// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.

You want to put your vendor JavaScripts in vendor/assets/javascripts not vendor/javascripts for them to be found.

Upvotes: 1

Related Questions