Rails rake assets:precompile isn't precompiled scss

juanito · 2012年04月02日 · 最后由 he9qi 回复于 2012年04月04日 · 4173 次阅读

大家好。

我的 Rails 要在本机试试看上 production 环境,上之前我要 rake assets:precompile

但它只编译 application.css ,其它目录底下的 *.scss.css 都不会编译。

有人知道该怎么解决吗?

目前里面只有一个 css + scss:

└── stylesheets
    ├── application.css
    └── projects.css.scss




我试过:

  • projects.css.scss 拿掉就 OK 了,但是我需要 scss ... ==> NO
  • config/enviroment/production.rb 里的 config.assets.compile = true ==> OK!
  • bundle exec rake assets:precompile ==> 同样的错误
  • 重装 gem -> 还是不行

环境 Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.1.0)
      actionpack (= 3.1.0)
      mail (~> 2.3.0)
    actionpack (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      i18n (~> 0.6)
      rack (~> 1.3.2)
      rack-cache (~> 1.0.3)
      rack-mount (~> 0.8.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.0.0)
    activemodel (3.1.0)
      activesupport (= 3.1.0)
      bcrypt-ruby (~> 3.0.0)
      builder (~> 3.0.0)
      i18n (~> 0.6)
    activerecord (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
      arel (~> 2.2.1)
      tzinfo (~> 0.3.29)
    activeresource (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
    activesupport (3.1.0)
      multi_json (~> 1.0)
    arel (2.2.3)
    bcrypt-ruby (3.0.1)
    builder (3.0.0)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.1)
      ffi (~> 1.0.6)
    coffee-rails (3.1.1)
      coffee-script (>= 2.2.0)
      railties (~> 3.1.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.2.0)
    cucumber (1.1.9)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.9.0)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.6)
    cucumber-rails (1.0.6)
      capybara (>= 1.1.1)
      cucumber (>= 1.0.6)
      nokogiri (>= 1.5.0)
    database_cleaner (0.7.2)
    diff-lcs (1.1.3)
    dynamic_form (1.1.4)
    erubis (2.7.0)
    execjs (1.3.0)
      multi_json (~> 1.0)
    factory_girl (3.0.0)
      activesupport (>= 3.0.0)
    ffi (1.0.11)
    gherkin (2.9.3)
      json (>= 1.4.6)
    hike (1.2.1)
    i18n (0.6.0)
    jquery-rails (1.0.19)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.6.6)
    mail (2.3.3)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.18)
    multi_json (1.2.0)
    nokogiri (1.5.2)
    polyglot (0.3.3)
    rack (1.3.6)
    rack-cache (1.0.3)
      rack (>= 0.4)
    rack-mount (0.8.3)
      rack (>= 1.0.0)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.1.0)
      actionmailer (= 3.1.0)
      actionpack (= 3.1.0)
      activerecord (= 3.1.0)
      activeresource (= 3.1.0)
      activesupport (= 3.1.0)
      bundler (~> 1.0)
      railties (= 3.1.0)
    railties (3.1.0)
      actionpack (= 3.1.0)
      activesupport (= 3.1.0)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    rspec (2.9.0)
      rspec-core (~> 2.9.0)
      rspec-expectations (~> 2.9.0)
      rspec-mocks (~> 2.9.0)
    rspec-core (2.9.0)
    rspec-expectations (2.9.0)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.9.0)
    rspec-rails (2.9.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.9.0)
    rubyzip (0.9.6.1)
    sass (3.1.15)
    sass-rails (3.1.6)
      actionpack (~> 3.1.0)
      railties (~> 3.1.0)
      sass (>= 3.1.10)
      tilt (~> 1.3.2)
    selenium-webdriver (2.20.0)
      childprocess (>= 0.2.5)
      ffi (~> 1.0)
      multi_json (~> 1.0)
      rubyzip
    sprockets (2.0.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.5)
    term-ansicolor (1.0.7)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.32)
    uglifier (1.2.4)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  capybara
  coffee-rails (~> 3.1.0)
  cucumber-rails (= 1.0.6)
  database_cleaner
  dynamic_form
  factory_girl
  jquery-rails
  rails (= 3.1.0)
  rspec-rails (~> 2.5)
  sass-rails (~> 3.1.0)
  sqlite3
  uglifier


rake 错误信息:

rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
mkdir -p /Users/Juanito/projects/rails-in-action/ticketee/public/assets
mkdir -p /Users/Juanito/projects/rails-in-action/ticketee/public/assets
mkdir -p /Users/Juanito/projects/rails-in-action/ticketee/public/assets
mkdir -p /Users/Juanito/projects/rails-in-action/ticketee/public/assets
rake aborted!
projects isn't precompiled
(in /Users/Juanito/projects/rails-in-action/ticketee/app/assets/stylesheets/projects.css.scss)

Tasks: TOP => assets:precompile
(See full tr​​ace by running task with --trace)




先说声谢谢了

maybe RAILS_ENV=production bundle exec rake assets:precompile

projects.css.scss 放出来看看

project.css.scss 沒改過:

// Place all the styles related to the projects controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

也試過: config.assets.precompile += %w( project.css.scss ) ==> 不行

鬱悶。。。

#1 楼 @he9qi 試過不行,謝謝!

ummm.. 你的 sass-rails 的 version 是什么。。gemfile.lock 里面~

#3 楼 @Juanito 试试 config.assets.precompile += %w(project.css)

别加 scss 尾坠

#6 楼 @hayeah 也是不行欸。。。

我打算升级 Rails 到 3.1.3 试试

#8 楼 @Juanito ~> 3.1.1 试试看吧

需要 登录 后方可回复, 如果你还没有账号请 注册新账号