2014-04-15 16 views
11

Devrim modlarımdaki raylarım uygulaması tam olarak istediğim gibi görünüyor, ancak üretimde krom ve safari'den farklı görünüyor, safari'de logo resimleri yükleniyor ancak yazı tipi değil , kromda yazı tipi yükler ancak resim değil, giriş alanları kromda biraz daha uzun ve yanlış hizalanmış ancak dev modda hepsi kromda harika görünüyorÖnceden yüklemeyen raylar var, css üretimde farklı görünüyor

Bir süredir bununla uğraştım ve herkesi sildim/varlıklar bir kaç kez

hiçbir başarı ile
rake assets:precompile RAILS_ENV=production 

yaptım ön derleme hatasız geçer

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" 

config/ortamlar/üretim: En config/environments/production.rb dosyasında

# 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' 
+1

Üretim ortamınız nedir? Heroku'ya mı gidiyorsun? – winston

+0

hayır Kendi kutusunda benim Nituel.IO üzerinde puma kullanıyorum – franklinexpress

+1

Nginx'i de kullanıyor musunuz? Yapılandırmayı ayarlamanız gerekebilir.serve_static_assets, üretim yapılandırmanızda yanlış. Ayrıca logonuz ve CSS linkleriniz için kodunuzu gönderebilir misiniz? – winston

cevap

11

, set:

config.serve_static_assets = false (şu anda doğru şekilde ayarlanmış)

config.assets.compile = true(şu an false olarak ayarlanmıştır)

Sorununuzu çözmelisiniz.

Yapmanızı istediklerimi açıklamama izin verin. config.serve_static_assets = false, biz söylüyoruz raylar sunucusu ayarlayarak

  • , statik öğelerini sunması için kullanılır ActionDispatch::Static ortakatmanlar eklemeyin.

Neden değil?

Bunun nedeni, üretim ortamınızda, uygulama sunucunuzu (puma gibi) bir web sunucusunun (Apache/Nginx gibi) arka planını çalıştırmanızdır. uygulama sunucusu raylarına talep.

Web sunucusu kullanmıyorsunuz, onu kapatıyoruz.

  • config.assets.compile = true ayarlanarak, istenen varlığı çalışma zamanında derlemek için raylara söylüyorum. İstenen varlığı app/assets, vendor/assets, lib/assets'da arayın ve bu konumlardan herhangi birinden bulunursa servis yapın. Varsayılan olarak

, config.assets.compile üretim ortamında geliştirme true, false olduğunu. Biz, statik varlıklara hizmet etmek için web sunucusu kullanmıyoruz, varlıklarımızı derlemek için raylar istiyoruz.

Daha fazla detay için asset pipeline documentation'a bakınız.

+0

'config.assets.compile = true' benim için kicker oldu. Bazen ayarlarla yapılan yorumlar, sahip olduğu etkiyi açıklığa kavuşturmaz. Bu gerçekten daha fazla raylar derlenmiş varlıkları beklemek gibi, gerçekten bu raylar _itself_ onları derlemesi gerekir değil. – Volte

İlgili konular