【发布时间】:2014-01-19 11:29:48
【问题描述】:
我开始学习 Rails 3.1。但是,css 不起作用。
app/assets/stylesheets/里面有一些scss,但是没有出现在application.css中
我创建 productshoge.css(不是 scss),但它也不起作用。
我认为“这将自动包含此目录中可用的所有样式表”,但不包含任何 css。
当我尝试重新制作新应用程序(rails new XXX)时,我遇到了同样的情况。
有人能给我建议吗?
文件夹
应用程序/资产/样式表/
├── application.css
├── carts.css.scss
├── layout.css.scss
├── line_items.css.scss
├── products.css.scss
├── productshoge.css
├──scaffolds.css.scss
└── store.css.scss
assets.path
irb(main):001:0> y Rails.application.config.assets.paths
---
- /Users/sekai/study/depot/app/assets/images
- /Users/sekai/study/depot/app/assets/javascripts
- /Users/sekai/study/depot/app/assets/stylesheets
- /Users/sekai/study/depot/vendor/assets/stylesheets
- /Library/Ruby/Gems/2.0.0/gems/jquery-rails-3.0.4/vendor/assets/javascripts
application.css
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. 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 productshoge.css
*= require_tree .
*/
输出(view-source:http://localhost:3000/?debug_assets=1)
<html>
<head>
<title>Pragprog Booksオンラインストア</title>
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" /><!-- <label id="code.slt"/> -->
<script src="/assets/application.js?body=1" type="text/javascript"></script><!-- <label id="code.jlt"/> -->
<meta content="authenticity_token" name="csrf-param" />
<meta content="asIA91Z9Dm0OnAPa4ki6LlWcUst/GypczrubeGSDegM=" name="csrf-token" /><!-- <label id="code.csrf"/> -->
</head>
输出 css
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. 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 productshoge.css
*= require_tree .
*/
环境
发展
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1