【问题标题】:Assets not found rails 4 + Capistrano 3 + Puma资产未找到 rails 4 + Capistrano 3 + Puma
【发布时间】:2016-04-22 11:12:02
【问题描述】:

我已将我的 rails 项目部署到 AWS。我在Gemfile 中有关注:

group :development do
  gem 'capistrano'
  gem 'capistrano3-puma'
  gem 'capistrano-rails', '~> 1.1'
  gem 'capistrano-bundler', require: false
  gem 'capistrano-rvm'
end

在我的production.rb

  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.assets.compile = true
  config.assets.digest = true

但是,当我在 Web 浏览器中加载我的应用程序时,我在控制台中看到我的 application-xxxxxx.cssapplication-xxxxxx.js 给出了 404 not found 错误。此外,当我去服务器并在 public/assets/ 文件夹中查找文件时,application-xxxxxx.js 存在于那里。

谁能帮我解决这个问题?

【问题讨论】:

  • 我能看到的唯一日志是<html> <head><title>404 Not Found</title></head> <body bgcolor="white"> <center><h1>404 Not Found</h1></center> <hr><center>nginx/1.4.6 (Ubuntu)</center> </body> </html> for application-xxxxxxx.css
  • 您是否运行了 bundle exec rake assets:precompile??部署后
  • 我不需要这样做,因为服务器中的资产已经在 public/assets/application-xxxxxx.js 和 css 中可见。 Capistrano 正在这样做。

标签: ruby-on-rails assets capistrano3 puma


【解决方案1】:

问题不在于资产编译和部署。我不得不在 nginx 配置文件 /etc/nginx/sites-enabled/default 中将路径从 root /home/deploy/portal/public; 更改为 /home/deploy/portal/current/public;

【讨论】:

    猜你喜欢
    • 2014-10-10
    • 2015-12-16
    • 1970-01-01
    • 2016-08-12
    • 2018-09-12
    • 2023-03-03
    • 2016-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多