嗨我無法讓我的CSS加載在我的基本導軌應用程序。我做了rails g controller static_pages
這給了我一個static_pages.scss應該由資產管道默認加載權?我有require_tree。在我application.css文件:爲什麼我的rails應用程序中的基本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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
這裏是我的static_pages.scss文件:
// Place all the styles related to the static_pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
body {
background-color: red;
}
當我查看static_pages#主頁的背景是白色的,所以CSS沒有加載。
這裏是我的application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>t</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body class="container-fluid">
<%= yield %>
</body>
</html>
我還沒有更改任何配置應用程序。謝謝您的幫助。
你有沒有重新啓動你的網絡服務器? – davideghz
是的,我已經多次重新啓動它 – srlrs20020
我搜索了一下,發現這個:'RAILS_ENV =開發耙資產:乾淨' - 在你的終端中運行它。這應該刪除您生成的CSS文件並強制導軌從Sass或SCSS文件重新生成CSS輸出。 – davideghz