gpt4 book ai didi

ruby-on-rails - 图标未显示在 heroku 中,但它们在本地

转载 作者:数据小太阳 更新时间:2023-10-29 08:22:34 24 4
gpt4 key购买 nike

应用.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

在本地,图标正常工作。

我的 gem 文件

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

我还需要更改什么 :(

最佳答案

试试这个,不管你的 CSS 文件是什么字体定义,把它变成一个 .scss 文件,然后使用 helpers 来获得正确的路径:

@font-face {
font-family: "moon";
src: font-url("icomoon.eot");
src: font-url("icomoon.eot?#iefix") format("embedded-opentype"),
font-url("icomoon.svg#moon") format("svg"),
font-url("icomoon.woff") format("woff"),
font-url("icomoon.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}

请注意,我还从路径中删除了 fonts/font-url 助手会处理这个问题,我假设字体在您的 app 中/assets/fonts 目录。这还假设您正在使用 sass-rails(这提供了帮助程序)。

关于ruby-on-rails - 图标未显示在 heroku 中,但它们在本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27553548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com