我遇到了上述错误。我已经看到很多问题的答案是“重新启动 Rails 服务器”。但这不是我的情况,因为这不是 Rails 服务器错误。
由于我的项目在 Heroku 中运行不佳(下拉菜单不起作用),但在本地环境中做得非常好,我试图在部署之前编译所有资产,bundle exec rake assets:precompile
但它抛出了错误:
~/.rvm/rubies/ruby-1.9.3-p448/bin/ruby ~/.rvm/gems/ruby-1.9.3-p448@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
File to import not found or unreadable: mycustom.scss.
Load path: ~/RubyProjects/sample_app_2
(in ~/RubyProjects/sample_app_2/app/assets/stylesheets/application.css)
我发现这是一个 sass 问题,所以我运行了 bundle exec sassapp/assets/stylesheets/mycustom.scss
但它会引发错误:
Syntax error: File to import not found or unreadable: bootstrap
Load path: ~/RubyProjects/sample_app_2
所以我认为问题在于项目中的某个地方不包含引导程序。因为如果我跑
bundle exec sass ~/.rvm/gems/ruby-1.9.3-p448@scaffold-example/gems/bootstrap-sass-2.0.0/vendor/assets/stylesheets/_bootstrap.scss
它显示了 4000 多行 CSS。
难道我做错了什么?
我应该做点别的吗?
这是我的 Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'sass-rails', '3.2.4'
#gem 'bcrypt-ruby', '3.1.1.rc1', :require => 'bcrypt'
#gem 'bcrypt-ruby', '3.1.0', :require => 'bcrypt'
#gem 'bcrypt-ruby', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
#gem 'bcrypt-ruby', git: 'git@github.com:hananamar/bcrypt-ruby.git', :require => 'bcrypt'
#gem 'bcrypt-ruby', :require => 'bcrypt'
group :development do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
gem 'annotate', '~> 2.4.1.beta'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.1'
#Test gems on Linux
group :test do
gem 'rspec-rails', '2.9.0'
gem 'capybara', '1.1.2'
gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
gem 'factory_girl_rails', '1.4.0'
end
group :production do
gem 'pg', '0.17.0'
end
#T#est gems on Windows
#group :test do
# gem 'rspec-rails', '2.9.0'
# gem 'capybara', '1.1.2'
# gem 'rb-fchange', '0.0.5'
# gem 'rb-notifu', '0.0.4'
# #gem 'win32console', '1.3.0'
# gem 'guard-spork', '0.3.2'
# gem 'spork', '0.9.0'
# gem 'factory_girl_rails', '1.4.0'
#end
和 mycustom.scss
@import "bootstrap";
/* mixins, variables, etc. */
$lightGray: #999;
$grayMediumLight: #eaeaea;
@mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* universal */
html {
overflow-y: scroll;
}
body {
padding-top: 60px;
}
section {
overflow: auto;
}
textarea {
resize: vertical;
}
.center {
text-align: center;
h1{
margin-bottom: 10px;
}
}
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.7em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $lightGray;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
#logo {
float: left;
margin-right: 10px;
font-size: 1.7em;
color: #fff;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
line-height: 1;
&:hover{
color: #000;
text-decoration: none;
}
}
footer {
margin-top: 45px;
margin-left: 100px;
margin-right: 100px;
padding-top: 5px;
border-top: 1px solid #eaeaea;
color: $lightGray;
a{
color: #555;
font-weight: bold;
&:hover{
color: $lightGray;
}
}
small{
float: left;
}
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 10px;
}
}
}
/* sidebar */
aside {
section {
padding: 10px 0;
border-top: 1px solid $grayLighter;
&:first-child {
border: 0;
padding-top: 0;
}
span {
display: block;
margin-bottom: 3px;
line-height: 1;
}
h1 {
font-size: 1.6em;
text-align: left;
letter-spacing: -1px;
margin-bottom: 3px;
}
}
}
.gravatar {
float: left;
margin-right: 10px;
}
/* miscellaneous */
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
@include box_sizing;
}
/* forms */
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
height: auto;
margin-bottom: 15px;
@include box_sizing;
}
#error_explanation {
color: #f00;
ul {
list-style: none;
margin: 0 0 18px 0;
}
}
.field_with_errors {
@extend .control-group;
@extend .error;
}