资产管道没有正确生成sass image-urls - 缺少资产路径

时间:2012-03-05 19:49:55

标签: ruby-on-rails-3 asset-pipeline

我正在将我的应用程序从Rails 3.0升级到3.1.3(在我从2.3升级之前)。现在我想启用资产管道。

我已经移动了样式表,现在我的清单文件看起来像这样

app.scss

@import "base";

_base.scss

.drawTrack {
    background-image: image-url('buttons/edit-20.png') !important;
}

但是生成的css缺少'资产'路径

app.css

.drawTrack {
  background-image: url('/buttons/edit-20.png') !important; 
}    

在我的Gemfile中我有

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

application.rb中

config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

# Precompile *all* assets, except those that start with underscore
config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
config.prefix = 'assets'

development.rb

# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true

之前我曾使用过jammit,但我现在删除了它。

可能有关系。 请求/assets/index.js返回正确的javascript文件,但是生成的路径/assets/index.js?body=1会返回一个空白的javascript。

THX

1 个答案:

答案 0 :(得分:0)

自己找到答案 必须更新application.rb并用

替换bundler行
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
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