Rails不一致地为资产提供服务

时间:2016-05-06 20:39:40

标签: ruby-on-rails nginx asset-pipeline unicorn

我有一个与Unicorn和Nginx一起提供的Rails 4.1.4应用程序。我使用this指南进行了设置。我遇到的问题是,当我加载网页时,资产不会加载大约40%的时间。

当资源加载时,chrome的控制台会显示请求已转到:

http://10.1.1.150:8080/stylesheets/application.css

给出404,当他们执行加载时显示:

http://10.1.1.150:8080/assets/application-acc2ff90682d6f0f7a3ba59e8bffcc1e.css

什么会导致资产的路径改变?

修改

这是我的布局代码。

    <!DOCTYPE html>
<html>
  <head>
    <title>TicketTracker</title>
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <nav class="navbar navbar-light" style="background-color: #e3f2fd;">
      <%= link_to "Ticket Tracker", tickets_path, class: "navbar-brand" %>
      <ul class="nav navbar-nav">
        <li class="nav-item">
          <%= link_to "Open Tickets", tickets_path(status: "open"), class: "nav-link" %>
        </li>
        <li class="nav-item">
          <%= link_to "Closed Tickets", tickets_path(status: "closed"), class: "nav-link" %>
        </li>
      </ul>
      <% if logged_in? %>
        <%= link_to "Logout (#{current_user.email})", :logout, method: :post, class: "pull-right" %>
      <% else %>
      <%= link_to "Login", new_user_session_path, class: "pull-right" %>
      <% end %>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <%= bootstrap_flash %>
        <%= yield %>
      </div>
    </div>
  </body>
</html>

1 个答案:

答案 0 :(得分:0)

删除然后重新编译然后重新启动服务器修复它。