【发布时间】:2014-05-30 11:57:09
【问题描述】:
我的 rails 应用程序在开发模式下可以正常工作并且看起来完全符合我的要求,但在生产中它在 chrome 和 safari 上看起来不同,在 safari 中加载徽标图像而不是字体,在 chrome 中加载字体而不是图像加上输入字段在 chrome 中稍长且未对齐,但在开发模式下,在 chrome 中看起来都很棒
我已经搞砸了一段时间,并删除了几次公共/资产
rake assets:precompile RAILS_ENV=production
没有成功,预编译通过,没有错误
config/application.rb:
# 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.
config.assets.paths << "#{Rails.root}/assets/fonts"
config.assets.paths << "#{Rails.root}/assets/images"
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile += %w( .svg .eot .woff .ttf )
# 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
config.assets.enabled = true
#config.assets.paths << "#{Rails.root}/app/assets/fonts"
配置/环境/生产:
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
#config.assets.compile = true
config.assets.precompile = ['*.js', '*.css', '*.css.erb', '*.css.scss']
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
config.assets.paths << "#{Rails.root}/assets/fonts"
config.assets.paths << "#{Rails.root}/assets/images"
config.assets.precompile += %w( .svg .eot .woff .ttf )
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
【问题讨论】:
-
你的生产环境是什么?您要部署到 Heroku 吗?
-
不,我在 puma 上运行的 Nitrous.IO 上使用我自己的盒子
-
你也在运行 nginx 吗?您可能需要在生产配置中将 config.serve_static_assets 设置为 false。您也可以发布您的徽标和 CSS 链接代码吗?
-
没有运行nginx,如果我在production.rb和application.rb中有重复的设置有关系吗?
-
欢迎在这里查看我的配置文件:jamestansley.com/2013/06/23/…。自从我部署到 Heroku 后,一些设置会有所不同,但请查看我的预编译设置。还要确保在布局中使用正确的 CSS 样式表链接
标签: css ruby-on-rails ruby-on-rails-4 assets