【问题标题】:compass-rails isn't letting me do @import compass/resetcompass-rails 不让我做@import compass/reset
【发布时间】:2012-08-16 06:55:25
【问题描述】:

我在启动应用程序时收到此错误:

File to import not found or unreadable: compass/reset.
Load path: /Users/nbenes/projects/lawgical_admin
  (in /Users/nbenes/projects/lawgical_admin/app/assets/stylesheets/screen.css.sass)

(堆栈跟踪:)

app/assets/stylesheets/screen.css.sass:2
app/views/layouts/login.html.haml:7:in `_app_views_layouts_login_html_haml__1550030126632827390_2194381580'

引发错误的文件如下所示:

app/assets/screen.css.sass

// This import applies a global reset to any page that imports this stylesheet.
@import compass/reset

它在 import 行上崩溃了,我不知道如何让它看到指南针宝石。

我的 gemfile 有这个:

Gemfile

group :assets do
  gem 'sass-rails', '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'compass-rails'
end

指南针配置是准系统:

config/compass.rb

# Require any additional compass plugins here.
project_type = :rails

最后,样式表被拉到视图中:

app/views/layouts/login.html.haml

= stylesheet_link_tag 'screen', :media => 'screen, projection'

不知何故,它只是没有看到指南针或导入它。我尝试跳过 compass/reset 导入,但后来它在 @import blueprint 处死掉了

在某些情况下,我正在将此应用程序升级到 rails 3.2 并使用资产管道而不是 Jammit 来编译资产(Jammit gem 和配置文件已被删除)。知道出了什么问题吗? :(

【问题讨论】:

  • 你看到这个问题了吗? github.com/chriseppstein/compass/issues/654 看起来你可以尝试从资产组中删除 gem 'compass-rails',或者如果你在 heroku 上部署,将 config.assets.initialize_on_precompile 设置为 false
  • 是的,我尝试从资产组中移出...但只有在生产环境中担心这一点时,这才是一个问题。我只是想让事情在开发中发挥作用。

标签: ruby-on-rails ruby-on-rails-3.2 sass asset-pipeline compass-sass


【解决方案1】:

当从 Rails 3.0.x 升级到 Rails 3.2.x 时,我错过了对 config/application.rb 的一个非常小但非常重要的更改

在 rails 3 中有一行写着:

Bundler.require(:default, Rails.env) if defined?(Bundler)

我升级失败的内容如下:

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)   
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    相关资源
    最近更新 更多