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.
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.
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:
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!
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.
For reference, here is my 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.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:
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
Is there a chance you have an empty image URL somewhere? Do you have something like CarrierWave installed?
I see from your code image_tag result.image
serves up - is it possible this is null?
This thread should solve it: ActionView::Template::Error ( isn't precompiled):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With