application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Gcp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Heroku requires this to be false
config.assets.initialize_on_precompile = false
end
end
我在推送到heroku之前做了预编译
@font-face {
font-family: "moon";
src: url("fonts/icomoon.eot");
src: url("fonts/icomoon.eot?#iefix") format("embedded-opentype"), url("fonts/icomoon.svg#moon") format("svg"), url("fonts/icomoon.woff") format("woff"), url("fonts/icomoon.ttf") format("truetype");
font-weight: normal;
font-style: normal; }
但是,当我启动网站时,它没有任何图标。
https://myapp.herokuapp.com/assets/slide4.jpg
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/img/timer.png
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/img/loader.gif
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/img/large_right.png
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/img/large_left.png
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/fonts/icomoon.woff
Failed to load resource: the server responded with a status of 404 (Not Found) https://myapp.herokuapp.com/assets/fonts/icomoon.ttf
GET https://myapp.herokuapp.com/assets/bootstrap.css.map 404 (Not Found) /assets/bootstrap.css.map:1
我还需要做些什么,以便将图标推到heroku后会显示出来。
我修复了CSS无法显示的问题,但现在看来它的路径不正确。
这不是在https://myapp.herokuapp.com/assets/fonts/icomoon.woff
他们在https://myapp.herokuapp.com/assets/home/fonts/icomoon.woff
等。
在本地,图标可以正常工作。
我的宝石文件
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'better_errors'
gem 'slim'
gem 'heroku'
group :production do
gem 'rails_12factor'
end
我还需要更改什么:(
一直以来,我都会遇到这个问题,即字体的路径不正确,您必须使用它来确保它,但是它应该类似于
@font-face {
font-family: "moon";
src: url("/assets/home/fonts/icomoon.eot");
src: url("/assets/home/fonts/icomoon.eot?#iefix") format("embedded-opentype"), url("/assets/home/fonts/icomoon.svg#moon") format("svg"), url("/assets/home/fonts/icomoon.woff") format("woff"), url("/assets/home/fonts/icomoon.ttf") format("truetype");
font-weight: normal;
font-style: normal; }
看到我在强文本之前添加了“ / assets /”
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句