Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rake资产:预编译不在heroku上工作_Ruby On Rails_Ruby On Rails 3_Heroku - Fatal编程技术网

Ruby on rails rake资产:预编译不在heroku上工作

Ruby on rails rake资产:预编译不在heroku上工作,ruby-on-rails,ruby-on-rails-3,heroku,Ruby On Rails,Ruby On Rails 3,Heroku,我的网站曾经正常工作,Heroku预先编译了这些资产和所有东西。现在,似乎不知从何而来,我开始让rake中止!部署时堆栈级别太深 从my application.css文件中删除行*=require_tree.似乎修复了堆栈级别太深的问题,但我得到了以下结果: Running: rake assets:precompile (in /tmp/build_b8o2t4k8frce) /usr/local/bin/ruby /tmp/build_b8o2t4k8frce/vendor/bundle/

我的网站曾经正常工作,Heroku预先编译了这些资产和所有东西。现在,似乎不知从何而来,我开始让
rake中止!部署时堆栈级别太深

从my application.css文件中删除行
*=require_tree.
似乎修复了
堆栈级别太深的问题
,但我得到了以下结果:

Running: rake assets:precompile
(in /tmp/build_b8o2t4k8frce)
/usr/local/bin/ruby /tmp/build_b8o2t4k8frce/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
(in /tmp/build_b8o2t4k8frce)
所有指向图像的链接都已断开(我在css文件中使用image-url()。可能是什么问题?我该如何解决

我使用的是cedar stack,这是我的文件:

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
以下是heroku使用的版本:

Using rake (0.8.7)
Using rails (3.1.0)
Using sass (3.1.15)
Using sass-rails (3.1.6)
这是我的application.rb文件

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

module App
  class Application < Rails::Application

    # 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'
  end
end
# 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

# Generate digests for assets URLs
config.assets.digest = true

您不必从application.css中删除此
*=require树。
,因为它会加载所有样式。只需添加它,然后像这样配置您的
config/production.rb
文件:

config.assets.precompile = %w{application.js}
并运行RAILS\u ENV=production rake assets:precompile

编辑 尝试使用此配置:

config.assets.digest  = true

显然,sass停止工作了,我失去了耐心,所以我决定不再使用它。而不是这样做:

#theme.css.scss
background-image:image-url('image.png');
现在我只使用一个erb文件:

#theme.css.erb
background-image:url(<%= asset_path 'image.png' %>);
#theme.css.erb
背景图片:url();

我为此损失了整整一天,我不知道为什么,因为就在昨天,它工作得很好。如果有人知道这是什么原因,以及我如何再次使用sass,请发表评论。

我遇到了类似的问题,并在这里找到了答案:。基本上,降级到sass rails v3.1.4。希望这有帮助

是的,这应该适用于
require_树
,但是如果我添加了它,那么我会中止
rake!堆栈级别太深
。我不知道这是怎么发生的对不起,我忘了抄那一行,我已经在用文摘了。我找到了一个解决办法,虽然我不太喜欢。哦,就是这样!这就解决了!问题是,我是一个新手,我认为这一行
gem'sass-rails',“~>3.1.0”
意味着我的gem版本被锁定了,但很明显,这个扭曲的hashrocket(或任何名称)让我们更新gem。也许事情就是这样,也许Heroku内部改变了一些东西,突然我的应用程序停止了工作。真奇怪,让我白白损失了一整天。对于任何可能在这里结束的人,解决方案是将该行更改为
gem'sass-rails',“3.1.4”
。谢谢-巨大的帮助-同样的问题,不知从何而来。这是我今天最不想看到的一件事,那就是push to heroku失败了。我注意到在一些使用sass的环境中,如果“:”和我语句中的值之间没有空格,我会出错,所以我不会写“background image:image url('image.png')”;写“背景图像:图像url('image.png')”[注意“:”后面的空格]