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 文件中添加任何行吗?

请帮我解决这个问题。

4

2 回答 2

0

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

config.assets.precompile += ['example/file1.css', 'example/file2.js','file3.js']
于 2015-01-17T18:04:41.877 回答
0

错误引用了这个:

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

这就是说if images are NOT nil, do x- 所以可能有东西回来了nilprecompile正试图访问和清空文件。你在用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,则如上所述,否则使用您用于上传图像文件的任何内容)并查看是否可以解决您的错误。

于 2013-09-08T13:29:10.427 回答