问题
I know it's related to assets, I do precompile the assets with
bundle exec rake assets:precompile
But the browser gives me 404 for only one javascript (jquery.formalize.min.js) file, which is not generated for some reason. There is however the code for jquery.formalize.min.js inside the precompiled application-xxxxxx.js.
I'm including it with:
<%= javascript_include_tag "formalize/jquery.formalize.min", "main" %>
And the error message in Chrome looks like:
GET http://example.com/assets/jquery.formalize.min-724f21bf646762e539aa18c8db1d4d43.js 404 (Not Found)
Full path to the formalize js file is app/assets/formalize/jquery.formalize.min.js.
Of course, application.js is loading fine.
<%= javascript_include_tag "application", "main" %>
How do I load the formalize/jquery.formalize.min.js? Thanks.
回答1:
Check your manifest file, which is app/assets/javascript/application.js by default. The //= entries control what files get pre-processed into the combined file.
回答2:
This was due to another fact, that Rails above v3 doesn't have somtething like:
config.assets.precompile += %w( *.js *.css )
See this issue for more.
来源:https://stackoverflow.com/questions/10177843/rails-3-javascript-is-not-found-when-running-in-production