18

我的网站过去可以正常工作,Heroku 预编译了资产和所有内容。现在,似乎不知从何而来,我开始在部署时收到此消息:

Preparing app for Rails asset pipeline
Running: rake assets:precompile
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets/icons
mkdir -p /tmp/build_31cexir1p9pwn/public/assets/icons
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
(in /tmp/build_31cexir1p9pwn)
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
rake aborted!
stack level too deep
(in /tmp/build_31cexir1p9pwn/app/assets/stylesheets/theme.css.scss)

(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation

它无法预编译我的 css 文件。

我正在使用雪松堆栈,这是我的 gemfile:

gem 'rails', '3.1.0'
gem 'rake', '0.8.7'
gem 'devise'

group :production do
  gem 'pg'
  gem 'thin'
end

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

这是我的 application.rb 文件

# Enable the asset pipeline
config.assets.enabled = true

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

这是我的 production.rb 文件

# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

# Enable Rails's static asset server (Apache or nginx will not need this)
config.serve_static_assets = true

# Set expire header of 30 days for static files
config.static_cache_control = "public, max-age=2592000"

# Allow JavaScript and CSS compression
config.assets.compress = true

# Compress JavaScript by removing whitespace, shortening variable names, ...
config.assets.js_compressor = :uglifier

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

现在我所有的图片链接都被破坏了(我在我的 css 文件中使用了 image-url() )。可能是什么问题,我该如何解决?

4

3 回答 3

30

我真的很绝望,所以我问了另一个问题。显然这是由 sass 引起的,降级到 sass-rails v3.1.4 v3.2.5 将使其工作。

于 2012-03-22T19:11:54.107 回答
1

升级到 sass v3.2.12 对我有用

但总的来说,看起来问题在所有当前版本上都已解决,只需进行捆绑更新,你应该会很好。

于 2013-11-11T20:00:45.960 回答
1

对于 ruby​​ 2.3.0 或更低版本,在 Rails 的application.rb文件中有以下行。但是 2.4.0 或更高版本已将这些实现为自动化。

Bundler.require(*Rails.groups)

将 ruby​​ 版本更改为 2.3.0 就可以了。这个拯救了我的一天。

于 2017-04-06T12:08:01.013 回答