29

我有一个全新的带有 Gemfile 的 Rails 4 应用程序:

#default gems
gem 'compass-rails'
gem 'zurb-foundation'
gem 'thin'

使用 style.scss:

@import "compass";
@import "foundation/variables";
$red: rgb(255,0,1);
$green: rgb(51,153,50);
$body-bg: #F4F4F4;
$body-font-color: #7B7B7B;
$primary-color: #999;
$secondary-color: #0CC;
$dark-color: #393939;
$block-container-border-color: rgb(218,218,218);
$block-container-shadow-color: rgb(208,208,208);
// main background
html{
  background:image-url('bckg.jpg');
}
body{
  width:1000px;
  margin:0 auto;
  @include box-shadow(0px 0px 32px -5px #000);
}

我有这个错误:

Showing /Users/quatermain/Projects/rails40/app/views/layouts/application.html.erb where line #18 raised:

File to import not found or unreadable: compass.
Load paths:
  /Users/quatermain/Projects/rails40/app/assets/images
  /Users/quatermain/Projects/rails40/app/assets/javascripts
  /Users/quatermain/Projects/rails40/app/assets/stylesheets
  /Users/quatermain/Projects/rails40/vendor/assets/javascripts
  /Users/quatermain/Projects/rails40/vendor/assets/stylesheets
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/turbolinks-1.2.0/lib/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/jquery-rails-3.0.1/vendor/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/coffee-rails-4.0.0/lib/assets/javascripts
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/zurb-foundation-4.2.3/scss
  /usr/local/rvm/gems/ruby-1.9.3-p392/gems/zurb-foundation-4.2.3/js
  (in /Users/quatermain/Projects/rails40/app/assets/stylesheets/style.scss:5)

Rails 4 目前不支持compass-rails吗?

4

6 回答 6

48

Compass 需要重写一些关键部分才能支持 Rails 4。您可以使用一个临时分支,其中包含一些支持:

'gem "compass-rails", github: "milgner/compass-rails", ref: "1749c06f15dc4b058427e7969810457213647fb8"

您可以关注https://github.com/Compass/compass-rails/pull/59以获取最新更新。

更新:

现在有一个 alpha 版本。

gem "compass-rails", "~> 2.0.alpha.0"

更新 2:compass-rails 不再处于 alpha 状态。

将以下内容添加到您的 Gemfile 并键入bundle install.

gem "compass-rails", "~> 1.1.2"
于 2013-07-15T00:04:34.113 回答
4

我最终使用了 Sunny Juneja 建议的 alpha 版本。

但是为了让它工作,我必须从我的 gemfile 中删除资产组:

# Not working:
group :assets do       # remove me olde line
   gem 'sass-rails',   '~> 4.0.0'
   gem 'compass-rails' # specify me version
end                    # remove me too, says aye

# Working:
gem 'sass-rails',    '~> 4.0.0'
gem 'compass-rails', '~> 2.0.alpha.0'
于 2013-09-19T22:41:29.247 回答
3

大约 18 小时前,compass-rails 的 stable 分支支持 Rails 4。从 Gemfile 中的 compass-rails 中删除版本字符串“2.0.alpha.0”并运行bundle update.

这是提交历史:

https://github.com/Compass/compass-rails/commits/stable

于 2013-12-09T18:39:15.457 回答
0

看来到目前为止(06/29/2013) compass-rails 不支持 Rails 4。当我运行时

rails generate foundation:install

我收到以下错误消息。

Unsupported rails environment for compass
于 2013-06-30T01:54:05.817 回答
0

我将所有指南针文件添​​加到我的供应商文件夹中并且它有效=),这可能不是更长时间=(。

于 2013-08-24T22:03:21.130 回答
-1

尝试这个:

gem 'sass-rails'
gem 'compass-rails', github: 'Compass/compass-rails'

您还应该确保这些不包含在您的资产组中,因为它已从 Rails 4.0 中删除。

然后删除您的Gemfile.lock文件并使用bundle命令重新生成它。

rm Gemfile.lock
bundle
于 2016-02-01T00:53:31.810 回答