简体   繁体   中英

Heroku Rails 4 not referencing my JavaScript assets location correctly

My local development runs fine, rendering javascript_include_tag "some-script" as referencing /assests/some-script.js correctly.

In Heroku, it references /javascripts/some-script.js

I'm using gem 'rails_12factor' in production in my Gemfile

Do I need to change any asset configuration settings? Like precompiling assets? I'm aware there are several config settings, but I'm unsure when to use them, in the past I've been fine without modifying them ( like this suggestion ).

It's just odd it references the /javascripts folder...

Also, to note, I am not currenty using javascript_include_tag "application" in layout/application.html.erb I am importing scripts manually using javascript_include_tag "some-script" in specific view erb files

Secondly, /assets/some-script.js comes up as a 404, so this must means my assests aren't available, which could be a second issue.

Any ideas?

This answer helped me resolve my issue. I had to manually add the js files to the assets precompile list in config/environments/production.rb like so:

config.assets.precompile += %w( some-script.js )
config.assets.precompile += %w( some-script2.js )
...

When I use a script in a view javascript_include_tag "some-script" works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM