我正在将Rails 2.5应用程序升级到Rails 3.1 rc4,我在开发中遇到了大量与资产管道相关的错误:
cache: [GET /assets/application-272985f6b5b17a3aeb1b84a6a376e225.css] miss, store
2011-07-06 16:03:56 +0300: Read error: #<NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each>
gems/ruby-1.9.2-p0/gems/rack-1.3.0/lib/rack/handler/mongrel.rb:90:in `process'
gems/ruby-1.9.2-p0/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:165:in `block in process_client'
gems/ruby-1.9.2-p0/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `each'
gems/ruby-1.9.2-p0/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `process_client'
gems/ruby-1.9.2-p0/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `block (2 levels) in run'
Run Code Online (Sandbox Code Playgroud)
基本上这里对application.css的请求返回一个空体.
首先,我认为它可能是一个服务器问题,所以我切换到webrick,但这没有帮助.
非常感谢帮助.;-)
尼科
我正在开发rails 3.1应用程序.
我在app/assets/images //中放了7张图片.
页面应该显示7个图像.但是我的浏览器没有显示所有图像.某些图像不会随机显示.有时不显示#1,2,3图像,有时不显示#6,7图像.
如果我在地址字段中键入图像地址,则图像显示良好.
这只发生在开发模式.生产模式很好地显示它们.
有没有人经历过同样的事情?
谢谢.
山姆
我正在使用Rails 3.2,我正在运行我的生产环境的一些问题.我运行了rake资产:precompile然后rails s -e production.这是我得到的错误:
Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Home#index
application_bottom.js isn't precompiled
Run Code Online (Sandbox Code Playgroud)
但当我查看我的公共/资产中有什么内容时
ls public/assets/application_bottom*
public/assets/application_bottom.js
public/assets/application_bottom.js.gz
Run Code Online (Sandbox Code Playgroud)
我注意到我应该有一个附加散列的文件,但我没有.我猜这可能与问题有关,但我不知道如何解决它.
这是我为环境配置的资产;
config.serve_static_assets = true
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
这是一个我正在升级到Rails 3.1的应用程序,以及资产管道.在开发过程中,一切看起来都很好看,但是当我推送到heroku时,我的CSS中的图像没有显示出来.
几个问题.首先,我应该将这些文件保留为css扩展,还是应该将它们重命名为scss或css.scss.erb?
我的另一个问题是如何在css中引用图像.目前我有......
background: #B4F4FF url(/assets/img01.jpg) repeat-x left top;^M
Run Code Online (Sandbox Code Playgroud)
我很确定我需要用'image_tag'或'asset_tag'替换url ...看起来有一些选项可用.此外,路径应该是什么?..... /资产,资产/图像,只是文件名???
我已经尝试了各种方法和路径,并且无法在Heroku中使用它.任何帮助赞赏!
即使文件为空,我也有错误导入扩展名为scss的文件.但是,如果我将该空文件的扩展名更改为css,那就行了!
当我将rails版本从3.2.3更改为3.2.15时,一切都开始发生了,因为bootstrap的下拉不起作用.
运行rails s命令没问题.但是,当我尝试推送到Heroku时,它会抛出错误:
要导入的文件未找到或不可读:custom.scss.
这是我的application.css文件:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, …Run Code Online (Sandbox Code Playgroud) 我想使用Devise 3和Rails 4将图像添加到我的确认电子邮件中。
我试过了...
Views / Devise / Mailer / confirmation_instructions.html.erb
<%= image_tag("my_image.png") %>
Run Code Online (Sandbox Code Playgroud)
...但是图像显示为默认的占位符问号。
我应该如何正确访问资产?
image devise asset-pipeline devise-confirmable ruby-on-rails-4
我最近改用CloudFront作为CDN,使用简单的服务
config.action_controller.asset_host = "url of your cloudfront distribution" 在我的配置文件中。
一切运行良好,CF吸收了它还不够好的资产,为它们提供了很好的服务,比使用资产管道更快。
但是,由于多种原因,从CF而非我们自己的服务器提供服务时,我们的某些JS会中断。因此,我正在寻找一种仅将CF用于图像(或图像/ css)资产的方法,并且仍然直接从我们自己的服务器提供已编译的application.js文件。
有任何想法吗?
在我的项目中,我们有一个单页应用程序,并且构建过程将应用程序编译为一个静态文件,位于public/index.html。
单页的应用程序负责处理在应用中的所有路由,所以无论你是否登陆site.com或site.com/foo/bar/action或者site.com/?,我想Rails应用程序服务public/index.html
我有这条路线:
match '*path', to: 'foo#index', via: :all
Run Code Online (Sandbox Code Playgroud)
在FooController中:
class FooController < ApplicationController
def index
render 'index.html', layout: false
end
end
Run Code Online (Sandbox Code Playgroud)
这不符合我的期望。我得到错误Missing template foo/index.html, application/index.html
public作为Rails控制器动作的一部分,是否可以提供资产?
我在Rails 4.0.8上有一个Heroku应用程序.
在早期的某个时刻,我意识到我的CSS和JS更改不会推送到Heroku,除非我rake assets:precompile在push(git push heroku master)之前运行并提交了新的资产文件.
我现在已经做了大约14个月的资产预编译了,而且我已经积累了超过48mb的旧版预编译资产.但是,当我从public/assets手动删除它们时,我的网站丢失了所有的CSS和JS.
如何删除旧的预编译资产并让Heroku在推送时开始编译?
我的Rails 5应用程序在开发中工作正常,但在生产中抛出了JS错误:
未捕获的ReferenceError:赋值中的左侧无效
在我的开发计算机上,只有生产服务器上不会发生此错误.javascript预编译为生产中的一行,因此我无法看到问题所在.
我尝试rake assets:precompile --trace RAILS_ENV=production在我的开发机器上运行,但它不会在那里抛出任何错误.
关于我如何尝试调试这个的任何线索?
asset-pipeline ×10
heroku ×2
ruby ×2
cdn ×1
devise ×1
git ×1
image ×1
javascript ×1
rake ×1
sass ×1