推送到Heroku时出现资产错误

3
在将我的应用程序推送到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文件中添加任何行吗?

请帮助我解决这个问题。

2个回答

0

错误指向这里:

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

这段代码的意思是:如果图片不为空,则执行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,则如上所述,否则使用任何用于上传图像文件的工具),看看是否可以解决您的错误。

0
在 production.rb 文件中,将文件名添加到以下行:
config.assets.precompile += ['example/file1.css', 'example/file2.js','file3.js']

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接