对于上下文,我基本上遵循本指南来设置我的rails应用程序:https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2
我的应用现在在AWS上运行: http://ems-heroes-dev.elasticbeanstalk.com/
运行Ruby 2.2(Puma)的64位Amazon Linux 2015.03 v2.0.1但是,我无法加载任何资产。
这是我的config / environments / production.rb:
EmsHeroes::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
config.assets.compress = true
config.assets.compile = true
# Bower asset paths
root.join('vendor', 'assets', 'components').to_s.tap do |bower_path|
config.sass.load_paths << bower_path
config.assets.paths << bower_path
end
# Precompile Bootstrap fonts
config.assets.precompile << %r(bootstrap-sass/assets/fonts/bootstrap/[\w-]+\.(?:eot|svg|ttf|woff2?)$)
# Minimum Sass number precision required by bootstrap-sass
::Sass::Script::Value::Number.precision = [8, ::Sass::Script::Value::Number.precision].max
config.less.paths << "#{Rails.root}/lib/less/protractor/stylesheets"
config.less.compress = true
# Generate digests for assets URLs.
config.assets.digest = true
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = false
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
end
我的资产通过heroku加载正常。 (但是,我不打算再使用heroku了)
修改 看起来它是rake资产的问题:预编译提供了错误的文件名。例如:我编译的css文件是:“public / assets / application-79dc234c01a4f604b52fc53ff49ac89d.css”但我得到404正在寻找“application.css”。将文件重命名为“public / assets / application.css”将正确加载它。
知道为什么会出现这种情况以及如何让它正确预编译?
答案 0 :(得分:0)
调用文件名后的此字符串&#34;摘要&#34;,它用于在文件内容更改时通知浏览器。您需要使用视图帮助程序(asset_path等)来获取带摘要的名称,或者您可以使用config.assets.digest = false
关闭此功能