导轨4支持导轨来提供静态资产:它是正确的吗? (在heroku上) [英] rails 4 enabled rails to serve static assets: is it correct? (on heroku)
问题描述
环境:heroku
Rails:4
Ruby:2
我们将一个应用程序部署到了heroku,并且好像公共文件夹中的任何内容都不可访问(没有看到静态文件,所以路由器启动后抱怨没有路由匹配)。
为了解决这个问题,我们设置了
pre code config.serve_static_assets =真正的
在我们的production.rb文件中。这真的是处理这个问题的最好方法吗?或者我们是否未能配置应用程序如何正确托管在heroku上?
在以前的Rails版本中,Heroku注入了一个插件,启用服务的静态资产,所以这个问题不存在。由于这个插件系统在Rails 4中被删除,他们现在创建了一个相同的gem。您可以通过以下方式在您的Gemfile中启用它: gem'rails_12factor',group :: production b $ b
您当然也可以为您的资产使用CDN,但您并不需要。
Environment: heroku
Rails: 4
Ruby: 2
We deployed an app to heroku, and it seemed as though anything in the public folder was not accessible (didn't see the static file so the router kicked in and then complains about no route matching).
To get around this, we set
config.serve_static_assets = true
in our production.rb file. Is this really the best way to handle this? Or did we fail to configure the app some how to be hosted on heroku properly?
In previous Rails versions, Heroku injected a plugin that enabled serving of static assets so this issue didn't exist. As this plugin system was removed in Rails 4, they now created a gem which does the same. You enable it in your Gemfile via:
gem 'rails_12factor', group: :production
See Getting Started with Rails 4.x on Heroku
You could also of course use a CDN for your assets, but you're not required to.
这篇关于导轨4支持导轨来提供静态资产:它是正确的吗? (在heroku上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!