加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – ActionView :: Template :: Error(不是预编译

发布时间:2020-12-16 22:18:57 所属栏目:百科 来源:网络整理
导读:更新: 事实证明,有时结果.image是nil或“”,所以这是打破了应用程序,因为资产管道正在寻找像“”而不是找到它的图像.现在我没有显示一个图像,如果没有一个,但我必须添加一个缺省的图像的默认图像…应该是一个更永久的修复. 我有一些关于这个问题的英雄雪松
更新:

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

我有一些关于这个问题的英雄雪松和Rails资产管道的问题,我已经尝试了一些解决方案,但没有一个工作,这可能是因为我遇到的问题有皱纹我还没见过别的地方

我的应用程序使用Rails 3.2.6,并将其部署在Heroku的雪松堆栈上.它是一个基本的搜索应用程序,通过websolr搜索附加的postgres数据库,所以当您加载索引(索引#索引)而不使用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 =分段耙资产:预编译(然后提交结果,当然),但这不能解决它.我甚至试图剥离出来(注意那里没有任何实际的造型).没有什么工作,我很失落.任何帮助将不胜感激.

作为参考,这里是我的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

这里是我的环境/ 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

解决方法

有没有机会你有空的图像网址?你有安装CarrierWave的东西吗?

我从你的代码中看到image_tag result.image提供了 – 这可能是null吗?

这个线程应该解决它:
ActionView::Template::Error ( isn’t precompiled):

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读