Rails 3, javascript is “not found” when running in production

♀尐吖头ヾ 提交于 2019-12-11 08:23:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!