[英]Rails app not loading assets on elastic beanstalk aws
對於上下文,我基本上遵循本指南來設置我的rails應用程序: https : //medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with -elastic-豆莖,和PostgreSQL相關3f9f29c046e2
我的應用程序現在在AWS上運行: http : //ems-heroes-dev.elasticbeanstalk.com/
運行Ruby 2.2的64位Amazon Linux 2015.03 v2.0.1(Puma)
但是,我無法加載任何資產。
這是我的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”將正確加載它。
知道為什么會出現這種情況以及如何讓它正確預編譯?
文件名后的此字符串稱為“摘要”,用於在文件內容更改時通知瀏覽器。 您需要使用視圖助手(asset_path等)來獲取帶摘要的名稱,或者您可以使用config.assets.digest = false關閉此功能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.