在生产中找不到样式表

时间:2013-10-13 18:00:33

标签: ruby-on-rails vps

我已经将一个准系统Rails部署到远程服务器,但是,它没有显示任何样式。如果我检查页面源代码,则会有一个指向样式表的链接(它使用twitter bootstrap gem)

 <link href="/assets/application-99190f98350e7ed3bb886d20f87bedfd.css" media="all" rel="stylesheet" />

但是当我点击链接时,我得到了404 Not Found

http://162.XXX.XXX/assets/application-99190f98350e7ed3bb886d20f87bedfd.css

 404 Not Found

nginx/1.4.3

javascript也一样。

我在ubuntu服务器上使用NGINX和Unicorn,根据Ryan Bates在他的Railscasts“部署到VPS”http://railscasts.com/episodes/335-deploying-to-a-vps?view=asciicast中的描述进行配置。如果我在远程服务器上查看css文件,它具有所有样式......

有谁知道问题可能是什么?如何在应用程序布局文件中指定样式表的完整路径?会避免这个问题吗?

/*
  =require twitter-bootstrap-static/bootstrap

  Use Font Awesome icons (default)
  To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
  =require twitter-bootstrap-static/fontawesome
  */


  html,
      body {
        height: 100%;
       /*   background-color: #;*/
        /* The html and body elements cannot have any padding or margin. */
      }

      /* Wrapper for page content to push down footer */
      #wrap {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        /* Negative indent footer by it's height */
        margin: 0 auto -60px;
      }

      /* Set the fixed height of the footer here */
      #push,
      #footer {
        height: 60px;
      }
      #footer {
        background-color: rgb(245, 240, 240);
      }

      /* Lastly, apply responsive CSS fixes as necessary */
      @media (max-width: 767px) {
        #footer {
          margin-left: -20px;
          margin-right: -20px;
          padding-left: 20px;
          padding-right: 20px;
        }
      }

      #wrap > .container {
        padding-top: 60px;
      }

a:visited {
color: #000;
}

ul, menu, dir {
list-style-type: none;

更新

nginx.conf
upstream unicorn {
  server unix:/tmp/unicorn.myapp.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  # server_name example.com;
  root /home/michael/apps/myapp/current/public;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

Application.css

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */

0 个答案:

没有答案