使用Heroku上已升级的应用程序将我的图像放在CSS中以在轨道和资产管道上工作 [英] Getting my images in css to work on rails and asset pipeline with upgraded app on Heroku

查看:65
本文介绍了使用Heroku上已升级的应用程序将我的图像放在CSS中以在轨道和资产管道上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个我正在升级到Rails 3.1的应用程序,以及资产管道.开发过程中一切看起来都像桃子一样,但是当我按下heroku时,css中的图像没有显示.

This is an app that I am upgrading to Rails 3.1, along with the asset pipeline. Everything looks peachy in development, but when I push to heroku, the images in my css are not displaying.

一对问题.首先,我应该保留这些文件的css扩展名,还是应将其重命名为scss或css.scss.erb?

Couple of questions. First, should I leave these files with the css extention, or should they be renamed to either scss, or css.scss.erb?

我的另一个问题是如何在CSS中引用图像.目前我有...

The other question I have is how should I reference images in the css. Currently I have...

  background: #B4F4FF url(/assets/img01.jpg) repeat-x left top;^M

我很确定我需要用'image_tag'或'asset_tag'替换url ...看起来有一些可用的选项.另外,路径应该是什么?...../资产,资产/图像,只是文件名?

I am pretty sure I need to replace url with either 'image_tag' or 'asset_tag'...looks like there are a few options available. Also, what should the path be?...../assets, assets/images, just the file name???

我尝试了所有方式的方法和路径,但无法在Heroku中使用.任何帮助表示赞赏!

I've tried all manner of methods, and paths, and can't get this to work in Heroku. Any help appreciated!

推荐答案

哇!要弄清楚这真是一个痛苦.

Wow! This was a real pain to figure out.

对我来说,问题集中在我应用程序中的静态页面上.我必须添加行...

For me the issue centered around static pages that I had in my app. I had to add the line...

  config.assets.precompile += ['static_pages.css']

转到config/environments/production.rb,然后使用

to config/environments/production.rb, then compile my assets locally with

RAILS_ENV=production bundle exec rake assets:precompile

然后将所有内容推送到heroku.

then push all that to heroku.

这篇关于使用Heroku上已升级的应用程序将我的图像放在CSS中以在轨道和资产管道上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆