ActionView :: Template :: Error(未预编译):在heroku雪松上

时间:2021-06-12 20:41:14

UPDATE:

更新:

It turns out that sometimes results.image was nil or "", so this was breaking the app because the asset pipeline was looking for an image like "" and not finding it. Right now I'm not showing an image if there isn't one, but I'll have to add a default image for missing images... that should be a more permanent fix.

事实证明,有时results.image是零或“”,所以这打破了应用程序,因为资产管道正在寻找像“”这样的图像而没有找到它。现在我没有显示图像,如果没有图像,但我将不得不为缺失的图像添加默认图像......这应该是一个更永久的修复。


I've a number of SO questions about this issue of heroku cedar and the Rails asset pipeline, and I've tried a number of solutions, but none of them works, and it's probably because the issue I'm having has a wrinkle that I've not seen anywhere else.

关于heroku cedar和Rails资产管道这个问题,我有很多问题,我已经尝试了很多解决方案,但是没有一个能够解决,而且可能是因为我遇到的问题有一个问题。我没见过其他任何地方。

My app uses Rails 3.2.6 and I've deployed it on Heroku's cedar stack. It's a basic search app that searches an attached postgres db via websolr, so when you load the index (index#index) without params[:q].present? you get a search box, and this works fine. But when I put something in the search box and hit submit, and index#index loads again but this time tries to display the results, I get:

我的应用程序使用Rails 3.2.6,我已经将它部署在Heroku的雪松堆栈上。这是一个基本的搜索应用程序,通过websolr搜索附加的postgres数据库,所以当你加载索引(索引#index)没有params [:q] .present?你有一个搜索框,这很好用。但是当我在搜索框中输入内容并点击提交,并且索引#index再次加载但这次尝试显示结果时,我得到:

app[web.1]: Completed 500 Internal Server Error in 440ms
app[web.1]: 
app[web.1]: ActionView::Template::Error ( isn't precompiled):
app[web.1]:     12:         - @results.each do |result|
app[web.1]:     13:           %li
app[web.1]:     14:             %div
app[web.1]:     15:               = image_tag result.image
app[web.1]:     16:             %div
app[web.1]:     17:               = result.title
app[web.1]:     18:             %div
app[web.1]:   app/views/index/index.html.haml:15:in `block in _app_views_index_index_html_haml___4350601325072829986_32734540'
app[web.1]:   app/views/index/index.html.haml:12:in   _app_views_index_index_html_haml___4350601325072829986_32734540'

What's bizarre about my particular case vs. others I've seen is the following line:

关于我的特殊情况和我见过的其他人有什么奇怪的是以下几行:

ActionView::Template::Error ( isn't precompiled):

With all of the other questions like this I've seen, there's a css file in the parenthesis, i.e. ("foo.css" isn't precompiled), or in my case it seems like it should be ("index.css" isn't precompiled). But here it's just blank!

对于我所见过的所有其他问题,括号中有一个css文件,即(“foo.css”未预编译),或者在我看来它似乎应该是(“index.css”)没有预编译)。但这里只是空白!

This is my staging deploy that I'm trying to get to work, so I've tried running RAILS_ENV=staging rake assets:precompile (then committing the results, of course), but that doesn't fix it. I even tried stripping out the in the view (notice the lack of any actual styling there). Nothing works, and I'm at a loss. Any help would be greatly appreciated.

这是我试图开始工作的暂存部署,所以我尝试运行RAILS_ENV =暂存rake资产:precompile(然后提交结果),但这并没有解决它。我甚至尝试在视图中剥离(注意那里没有任何实际的样式)。什么都行不通,我很茫然。任何帮助将不胜感激。

For reference, here is my gemfile:

供参考,这是我的gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.6'
gem 'pg'
gem 'haml-rails'
gem 'mongoid'
gem 'sunspot_rails', '~> 1.3.0'
gem 'sunspot_solr'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :development do
  gem 'heroku_san'
  gem 'annotate'
  gem 'awesome_print'
end

group :development, :test do
  gem 'rspec-rails'
end

group :test do
  gem 'cucumber-rails', :require => false
  gem 'capybara'
  gem 'database_cleaner'
  gem 'spork'
  gem 'launchy'
end

group :staging, :production do
  gem 'thin'
end

Here are the config options in my config/application.rb file:

以下是我的config / application.rb文件中的配置选项:

config.encoding = "utf-8"
config.filter_parameters += [:password]
config.active_support.escape_html_entities_in_json = true
config.active_record.whitelist_attributes = true
config.assets.enabled = true
config.assets.version = '1.0'
config.assets.compile = true

And here are the config options in my environments/staging.rb file:

以下是我的environment / staging.rb文件中的配置选项:

config.cache_classes = true
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.precompile += ['index.css.scss']
config.assets.digest = true
config.i18n.fallbacks = true
config.active_support.deprecation = :notify

1 个解决方案

#1


16  

Is there a chance you have an empty image URL somewhere? Do you have something like CarrierWave installed?

你有可能在某处有一个空图像URL吗?你有安装CarrierWave的东西吗?

I see from your code image_tag result.image serves up - is it possible this is null?

我从你的代码中看到image_tag result.image服务了 - 这可能是null吗?

This thread should solve it: ActionView::Template::Error ( isn't precompiled):

这个线程应该解决它:ActionView :: Template :: Error(未预编译):

#1


16  

Is there a chance you have an empty image URL somewhere? Do you have something like CarrierWave installed?

你有可能在某处有一个空图像URL吗?你有安装CarrierWave的东西吗?

I see from your code image_tag result.image serves up - is it possible this is null?

我从你的代码中看到image_tag result.image服务了 - 这可能是null吗?

This thread should solve it: ActionView::Template::Error ( isn't precompiled):

这个线程应该解决它:ActionView :: Template :: Error(未预编译):