你好我已经建立了自己的简单的配置文件,并维护我的代码在Heroku中,但图像没有得到加载Heroku。在这里我分享我的生产设置。Rails 5 - 图像不加载在Heroku
config.serve_static_assets = true
config.assets.compile = false
config.assets.digest = true
我使用的是ruby 2.3.0和rails 5.1。
你好我已经建立了自己的简单的配置文件,并维护我的代码在Heroku中,但图像没有得到加载Heroku。在这里我分享我的生产设置。Rails 5 - 图像不加载在Heroku
config.serve_static_assets = true
config.assets.compile = false
config.assets.digest = true
我使用的是ruby 2.3.0和rails 5.1。
在Rails应用程序5.x中,没有必要要求“rails_12factor”的宝石,因为它的功能现在包括是默认: https://github.com/heroku/rails_12factor#rails-5
只是测试和图像(/应用/资产/图像/ image.jpg的)用默认设置正确地加载在生产结构:
config.assets.compile = false
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
没有这个选项(在任何配置):
config.serve_static_assets = true
config.assets.digest = true
感谢Vladv,http://myoutline.herokuapp.com/这是我的网站网址。您现在可以看到图像正在加载,但字体很棒的图标未加载。 –
现在工作正常。我在production.rb中启用了config.assets.compile = true并且在生产环境中进行预编译,现在它工作正常。 –
这个问题有很多问题,你有尝试过吗? –
图像是指用户上传的资料或资产文件夹中的静态图像? – Sunny
位于“public”或“assets”中的图像在哪里?视图中包含的图像如何通过其名称或您使用资产管道?您是否尝试直接通过网址加载图片,是否有效? – spickermann