アップデート:
results.image が nil または "" であることが判明したため、アセット パイプラインが "" のような画像を探していて見つからなかったため、アプリが壊れていました。現在、画像がない場合は表示していませんが、欠落している画像のデフォルトの画像を追加する必要があります...これはより恒久的な修正になるはずです.
heroku cedar と Rails アセット パイプラインのこの問題について、SO に関する質問がいくつかあり、いくつかの解決策を試しましたが、どれもうまくいきませんでした。私は他のどこにも見たことがありません。
私のアプリは Rails 3.2.6 を使用しており、Heroku の cedar スタックにデプロイしました。付属のpostgres dbをwebsolr経由で検索する基本的な検索アプリなので、index(index#index)をロードするとparams[:q].present? 検索ボックスが表示され、これは正常に機能します。しかし、検索ボックスに何かを入力して送信すると、 index#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'
私の特定のケースと私が見た他のケースの奇妙な点は、次の行です。
ActionView::Template::Error ( isn't precompiled):
私が見たこのような他のすべての質問では、括弧内に css ファイルがあります。つまり (「foo.css」はプリコンパイルされていません)、または私の場合は (「index.css」プリコンパイルされていません)。しかし、ここは空白です!
これは私が作業を開始しようとしているステージング デプロイなので、RAILS_ENV=staging rake assets:precompile を実行してみました (もちろん、結果をコミットします) が、それは修正されません。ビューから を取り除いてみました (そこに実際のスタイルがないことに注意してください)。何も機能せず、途方に暮れています。どんな助けでも大歓迎です。
参考までに、私の 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
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
そして、これが私の 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