我的背景图像链接和glyphicons停止在Heroku中工作

时间:2014-12-14 11:06:50

标签: twitter-bootstrap ruby-on-rails-4 heroku

虽然我的本地主机中所有背景图片和字形都显示正确,但在我最新上传到Heroku后,他们停止了工作。所有其他图像都能正确显示。

我的背景图片定义为custom.css.scss as     background-image:asset-data-url(' bg-nav-dark.png'); 我也试过了     背景图像:网址(' BG-nav.png&#39);

bootstrap.css中的我的glyphicons定义为:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: font-url('glyphicons-halflings-regular.eot');
  src: font-url('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), etc.

当我在Heroku中检查我的主页时,控制台会显示以下错误:

GET https://peaceful-harbor-2916.herokuapp.com/assets/bootstrap.css.map 404 (Not Found) peaceful-harbor-2916.herokuapp.com/:11 
GET https://peaceful-harbor- 2916.herokuapp.com/assets/bootstrap.css.map 404 (Not Found) application-a29ac562c89a1c46b8f0515885102bda.js:3509 
GET https://peaceful-harbor-2916.herokuapp.com/assets/bg-texture.png 404 (Not Found) application-a29ac562c89a1c46b8f0515885102bda.js:3509 
GET https://peaceful-harbor-2916.herokuapp.com/assets/bg-nav.png 404 (Not Found) application-a29ac562c89a1c46b8f0515885102bda.js:3509 
GET https://peaceful-harbor-2916.herokuapp.com/fonts/glyphicons-halflings-regular.woff application-a29ac562c89a1c46b8f0515885102bda.js:3509 

等。等

(以上几行让我觉得预编译将资产放在Rails之后找不到它们的地方......) 将我的代码推送到Heroku后,我做了一个预编译并得到了这个回复:

$ heroku run rake assets:precompile Running `rake
assets:precompile` attached to terminal... up, run.3123 rake aborted!
Sass::SyntaxError: Invalid CSS after "...":3,"sources":[": expected
"|", was ""bootstrap.css"..."   (in /app/app/assets/stylesheets/application.css)

我将图像和字体存储在这些文件夹中:

/app
  /assets
    /fonts
    / images
    / stylesheets   

我不知道为什么,但预编译导致图像出现在路径中     /上市       /资产

在application.rb中我有以下几行:

config.assets.initialize_on_precompile = true  # I have tried false as well
config.i18n.enforce_available_locales = false
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.default_locale = :en
config.assets.paths << Rails.root.join("app", "assets")
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.paths << Rails.root.join("app", "assets", "images")

我的production.rb包含     config.serve_static_assets = true

我的application.css包含:

/*
 *= require jquery-ui/datepicker
 *= require_self
 *= require bootstrap
 *= require 'custom'
 *= require leaflet
 *= require_tree .
 */

这是我的Gemfile:

source 'https://rubygems.org'
source 'http://gemcutter.org'
source 'https://rails-assets.org'
gem 'rails', '4.1.7'
gem 'haml-rails'
gem 'bootstrap-sass', '~>3.2.0'
gem 'rails-assets-bootstrap'
gem 'rails-assets-leaflet'
gem 'sass', '~>3.2.0'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '~> 2.3.0'
gem 'jquery-ui-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'pg'
group :development do
  gem 'spring'
  gem 'rails_12factor'
end
gem 'rake', '~> 10.3.2'
gem 'paper_trail', '~> 3.0.6'
group :test, :development do
  gem 'rspec-rails'
  gem 'sqlite3'
  gem 'simplecov'
end
group :test do
  gem 'capybara', '~> 2.4.0'
  gem 'database_cleaner', github: 'bmabey/database_cleaner'
  gem 'factory_girl_rails'
end
gem 'bcrypt', '~> 3.1.7'
ruby "2.1.4"

请告诉我我错过了什么。

0 个答案:

没有答案