【问题标题】:Asset error while pushing to Heroku推送到 Heroku 时出现资产错误
【发布时间】:2013-09-08 13:12:19
【问题描述】:

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

请帮我解决这个问题。

【问题讨论】:

    标签: ruby-on-rails heroku asset-pipeline


    【解决方案1】:

    错误引用了这个:

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

    这是说if images are NOT nil, do x - 所以可能有东西回来了nilprecompile 正在尝试访问和清空文件。你在用carrierwave吗?

    查看this answer

    我假设您正在使用 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,如上,否则使用您用于上传图像文件的任何内容)并查看是否可以解决您的错误。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2021-08-26
        • 2011-10-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-12
        • 1970-01-01
        • 2019-06-01
        相关资源
        最近更新 更多