繁体   English   中英

推送到Heroku时出现资产错误

[英]Asset error while pushing to Heroku

在将我的应用程序推送到Heroku时,我收到以下错误

2013-09-08T12:58:32.140279+00:00 app[web.1]: ActionView::Template::Error ( isn't precompiled):
2013-09-08T12:58:32.140279+00:00 app[web.1]:     206:     <div class="tab-pane" id="tab5">
2013-09-08T12:58:32.140279+00:00 app[web.1]:     209:       <% if   !@orbituarysite.orbiturer_share_images.nil? %> <div class="well"><%   @orbituarysite.orbiturer_share_images.each do |f| %> <%=   image_tag(f.orbiturer_other_images_url(:thumb))  %><% end %></div><% end %>
2013-09-08T12:58:32.140279+00:00 app[web.1]:     210:         <a data-toggle="modal" href="#myModal5" class="btn btn-primary" href="/orbiturer_share_images/new">Post Notice</a>

但在推进Heroku预编译的同时发生了

   Using twitter-bootstrap-rails (2.2.8) from git://github.com/seyhunak/twitter-bootstrap-rails.git (at master)
   Using uglifier (2.2.1)
   Your bundle is complete! It was installed into ./vendor/bundle
   Cleaning up the bundler cache.
   Writing config/database.yml to read from DATABASE_URL
   Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_31lb8bborpfrx/Rakefile:7)
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_31lb8bborpfrx/Rakefile:7)
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_31lb8bborpfrx/Rakefile:7)
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_31lb8bborpfrx/Rakefile:7)
   Asset precompilation completed (240.04s)

什么可能是错误,预编译完成后,我仍然会收到错误。

我是否需要在production.rb文件中添加任何行?

请帮我解决这个问题。

错误引用了这个:

<% if !@orbituarysite.orbiturer_share_images.nil? %>

这就是说, if images are NOT nil, do x - 所以可能有些东西会返回nil并且precompile试图访问并清空文件。 你在使用carrierwave吗?

看看这个答案

我假设您使用像CarrierWave这样的东西来处理文件上传? 您可以在上传器类中指定默认图像处理程序:

https://github.com/jnicklas/carrierwave#providing-a-default-url

class MyUploader < CarrierWave::Uploader::Base
  def default_url
    "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  end
end

这将输出默认图像,而不是尝试访问资产管道中名为“”的不存在的文件。

尝试设置默认图像(如果使用carrierwave,则如上所述,否则使用上传图像文件的任何内容),看看是否可以排除错误。

在production.rb中,将文件名添加到以下行:

config.assets.precompile += ['example/file1.css', 'example/file2.js','file3.js']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM