1

我处于一个奇怪的境地。我有一个在 3.1 中创建的应用程序。它最近升级到 Rails 3.2.6,我第一次开始使用布局和视图。(别问。我一直在控制台模式下使用该应用程序并作为数据库管理器)

现在我有一个控制器和一些模型,当我访问默认页面时,一切都很好,但我在日志中看到以下错误:

Started GET "/stylesheets/application.css" for 127.0.0.1 at 2012-07-31 13:54:45 -0500

ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css"):
  actionpack (3.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.6) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.6) lib/rails/rack/logger.rb:16:in `call'

'app/assets/stylesheets' 中有一个 application.css 文件。它目前是空白的。

我见过很多其他人问这个问题,但似乎没有一个解决方案/答案适用于我,虽然我不能说为什么。这是我的 layout/application.html.erb 文件的样子:

<!DOCTYPE html>
<html>
<head>
    <% if current_user %>
        <title>MY TITLE - <%= current_user.full_name %></title>
    <% else %>
        <title>MY TITLE</title>
    <% end %>
    <%= stylesheet_link_tag    "application", :media => "all" %>
    <%= javascript_include_tag "application" %>
    <%= csrf_meta_tags %>
</head>
<body>
<div id="nav_div">
    <% if current_user %>
      Logged in as <%= current_user.name %> (<%= current_user.email %>).
      <%= link_to "Log Out", logout_path %>
    <% else %>
      <%= link_to "Sign Up", signup_path %> or
      <%= link_to "Log In", login_path %>
    <% end %>
</div>

<div id="flash_div">
    <% if flash[:alert] %>
      <p class="flash-error"><%= flash[:alert] %></p>
    <% end %>
    <% if flash[:notice] %>
      <p class="flash-notice"><%= flash[:notice] %></p>
    <% end %>   
</div>

<%= yield %>

</body>
</html>
4

1 回答 1

0

检查您是否在 application.rb 中打开了管道:

config.assets.enabled = true
于 2013-05-23T17:29:44.427 回答