2

我在生产中遇到 rails + nginx + unicorn 错误

ActionView::Template::Error(application.css 未预编译):

我正在尝试使用 sqlite3 部署干净的 rails 应用程序。当我访问http://cayennepower.ru/posts时,我很抱歉,但出了点问题。在首页上,静态欢迎页面效果很好。在我的 app/log production.log 我有这样的错误

Started GET "/posts" for 127.0.0.1 at 2012-12-12 06:47:48 +0100
Processing by PostsController#index as */*
Rendered posts/index.html.erb within layouts/application (0.4ms)
Completed 500 Internal Server Error in 3ms

ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4:   <title>CleanRails</title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in   `_app_views_layouts_application_html_erb___741543018_80365330'
app/controllers/posts_controller.rb:7:in `index'

在 config/enviroments/production.rb 我放置

config.assets.compile = true

config.assets.precompile += %w( application.css )

我已经运行了 rake assets:precompile --trace RAILS_ENV=production

跟踪日志是

** Invoke assets:precompile (first_time)
** Execute assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p327/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p327/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:nondigest

但我仍然有这个错误

我的 nginx.conf 是

    upstream cayennepower.ru {
   server unix:/home/sites/cayennepower.ru/www/tmp/sockets/unicorn.sock;
   # server 127.0.0.1:3000 fail_timeout=0;
}

我的 domain.conf 文件是

server {
listen 80;
server_name cayennepower.ru;
root /home/sites/cayennepower.ru/www/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
    #if (!-f $request_filename) {
        proxy_pass http://cayennepower.ru;
        break;
    #}
}

}

非常感谢你们的帮助!

4

0 回答 0