gpt4 book ai didi

ruby-on-rails - 错误 : File to import not found or unreadable: mycustom. scss。运行: rake Assets :预编译

转载 作者:数据小太阳 更新时间:2023-10-29 07:50:09 24 4
gpt4 key购买 nike

我遇到了上述错误。我见过很多答案是“重启 Rails 服务器”的问题。但这不是我的情况,因为这不是 Rails 服务器错误。

由于我的项目在 Heroku 中运行得不是很好(下拉菜单不起作用)但在本地环境中运行得非常好,我试图在使用 bundle exec rake assets:precompile 部署之前编译所有 Assets 但它抛出错误:

~/.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 sass app/assets/stylesheets/mycustom.scss

但它抛出错误:

Syntax error: File to import not found or unreadable: bootstrap
Load path: ~/RubyProjects/sample_app_2

所以我认为问题在于项目中某处未包含 Bootstrap 。因为如果我跑

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;
}

最佳答案

问题是 sass 没有按应有的方式处理我的 application.css。失败的不仅是 mycustom.css.scss 文件,还有所有扩展名为 .scss 的文件。

我不得不将我的 application.css 重命名为 application.scss

关于ruby-on-rails - 错误 : File to import not found or unreadable: mycustom. scss。运行: rake Assets :预编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19699057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com