Rails 2.3 应用未在独角兽服务器上正确发布(样式表获取 HTTP 404)

Rails 2.3 app is not being published correctly on unicorn server (stylesheets get HTTP 404)

我正在尝试将一个旧的 rails 应用程序部署到我的开发机器上的独角兽服务器。 问题是应用程序 运行 不正确,因为未显示样式表。

我正在通过捆绑程序启动服务器。

bundle exec unicorn

I, [2016-01-11T19:40:09.403219 #23668]  INFO -- : listening on addr=0.0.0.0:8080 fd=5
I, [2016-01-11T19:40:09.403357 #23668]  INFO -- : worker=0 spawning...
I, [2016-01-11T19:40:09.404184 #23668]  INFO -- : master process ready
I, [2016-01-11T19:40:09.405295 #23681]  INFO -- : worker=0 spawned pid=23681
I, [2016-01-11T19:40:09.405631 #23681]  INFO -- : Refreshing Gem list
worker=0 ready
127.0.0.1 - - [11/Jan/2016 19:41:33] "GET / HTTP/1.1" 304 - 0.1429
127.0.0.1 - - [11/Jan/2016 19:41:33] "GET /stylesheets/main.css?1311631772 HTTP/1.1" 404 664 0.1346

服务器日志显示 main.css 的 HTTP 404 并且应用程序正在呈现时没有 css 样式!

当 运行 在 WEBrick 服务器上时一切正常,所以根据 unicorn 这一定是一个特定的问题。

bundle exec script/server

=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2016-01-11 19:30:50] INFO  WEBrick 1.3.1
[2016-01-11 19:30:50] INFO  ruby 1.8.7 (2013-12-22) [i686-darwin14.5.0]
[2016-01-11 19:30:50] INFO  WEBrick::HTTPServer#start: pid=23474 port=3000

Gemfile:

source 'https://rubygems.org'
ruby '1.8.7'
gem 'rails', '2.3.5'
gem 'warden', '0.10.3'
gem 'devise', '1.0.6'
gem 'delocalize', '~> 0.1.4'
gem 'rdoc'
gem 'mysql'
gem 'unicorn', '4.9.0'

我设法通过使用那个 monkey hack 解决了这个问题: https://gist.github.com/defunkt/424352

为了生产,我不得不取消注释第 38 行和第 71 行中的 if 语句。