简体   繁体   English

Heroku上的Rails应用无法正常工作

[英]Rails app on Heroku not working

My js is not working on Heroku. 我的js无法在Heroku上运行。 As you can see in (the page is loaded but no content is showed) 如您所见(页面已加载,但未显示任何内容)

www.nmusicjungle.heroku.com

I guess the problem is the asset pipeline, destroying my js files 我想问题是资产管道破坏了我的js文件

Everything works fine on localhost, and you can see the result here 在localhost上一切正常,您可以在此处看到结果

www.musicjungle.com.br

I even tried to use config.assets.enabled = false in application.rb , but nothing changed on heroku. 我什至尝试在application.rb使用config.assets.enabled = false ,但是heroku上没有任何变化。

At first I was trying to let heroku compile the assets, but heroku failed. 起初,我试图让heroku编译资产,但是heroku失败了。 So I did assets:precompile on local machine (with no errors) and Heroku accepted the manifest file I'm using Ruby 2 and Rails 4 所以我做了assets:precompile在本地计算机上assets:precompile (没有错误),并且Heroku接受了我正在使用Ruby 2和Rails 4的清单文件。

Edit: Just to Add a bizarre behavior, the website is partly loaded on my tablet... lol 编辑:只是为了添加一个奇怪的行为,网站部分加载到我的平板电脑上...大声笑

config.assets.enabled = false

is not what you want. 不是你想要的。

Steps to troubleshoot, compile your assets locally with 故障排除步骤,使用以下命令在本地编译资产

RAILS_ENV=production bundle exec rake assets:precompile

Test your app locally before pushing 在推送之前先在本地测试您的应用

rails s -e production

Most likely you will want to play with the following settings in your "my environment".rb file 您很可能希望在“我的环境” .rb文件中使用以下设置

  config.serve_static_assets = true

 # Compress JavaScripts and CSS
 config.assets.compress = false

 # Don't fallback to assets pipeline if a precompiled asset is missed
 config.assets.compile = false

 # Generate digests for assets URLs
 config.assets.digest = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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