2013-07-17 4 views
11

मुझे उत्पादन में संपत्ति के साथ समस्या है।रेल 4 संपत्ति उत्पादन में नहीं मिली है (पाचन पथ ठीक है)

मैं स्टाइलशीट, जावास्क्रिप्ट या यहां तक ​​कि छवियों को लोड नहीं कर सकता।

जब मैं किसी चीज़ तक पहुंचने का प्रयास करता हूं, तो यह मुझे त्रुटि दिखाता है - नहीं मिला, लेकिन जब मैं -डिगेस्ट तक पहुंचने का प्रयास करता हूं, तो यह ठीक है।

मैं संपत्ति precompiled, सफलतापूर्वक प्रकट साथ Capistrano के माध्यम से तैनात किया है -> assets_manifest.json

धन्यवाद

प्रवेश स्टाइलशीट त्रुटि (स्टाइलशीट themes_for_rails मणि के साथ भरी हुई) जब मैं करने के लिए/आस्तियों/डिफ़ॉल्ट पहुँच कोशिश

: /stylesheets/application-ec9a310f792c60f2f77810cfcd9b903f.css, सब कुछ ठीक

I, [2013-07-17T14:38:45.120183 #31938] INFO -- : Started GET "/assets/default/stylesheets/application.css?locale=cs" for 90.181.17.25 at 2013-07-17 14:38:45 +0200 
I, [2013-07-17T14:38:45.123007 #31938] INFO -- : Processing by ThemesForRails::AssetsController#stylesheets as CSS 
I, [2013-07-17T14:38:45.123429 #31938] INFO -- : Parameters: {"locale"=>"cs", "theme"=>"navarsi", "asset"=>"application"} 
I, [2013-07-17T14:38:45.124912 #31938] INFO -- : Rendered text template (0.0ms) 
I, [2013-07-17T14:38:45.125177 #31938] INFO -- : Completed 404 Not Found in 2ms (Views: 0.5ms | ActiveRecord: 0.0ms) 

छवि लॉग त्रुटि है

ActionController::RoutingError (No route matches [GET] "/assets/icons/flags/24/cs.png"): 
    actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
    railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app' 
    railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call' 
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged' 
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged' 
    activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged' 
    railties (4.0.0) lib/rails/rack/logger.rb:21:in `call' 
    actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call' 
    rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' 
    rack (1.5.2) lib/rack/runtime.rb:17:in `call' 
    activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call' 
    railties (4.0.0) lib/rails/engine.rb:511:in `call' 
    railties (4.0.0) lib/rails/application.rb:97:in `call' 
    railties (4.0.0) lib/rails/railtie/configurable.rb:30:in `method_missing' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb:479:in `safe_fork' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:180:in `start' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:129:in `start' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize' 
    <internal:prelude>:10:in `synchronize' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' 
    /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/helper-scripts/passenger-spawn-server:99:in `<main>' 

यह मेरी उत्पादन वातावरण config

Project::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb. 

    config.assets.precompile << Ckeditor.assets 
    config.assets.precompile << %w(*/fonts/**/*.*) 
    config.assets.precompile << %w(*.png *.jpg *.jpeg *.gif) 

    # 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 

    # Compress JavaScripts and CSS. 
    config.assets.js_compressor = :uglifier 
    config.assets.css_compressor = :sass 

    # Do not fallback to assets pipeline if a precompiled asset is missed. 
    config.assets.compile = false 
    # config.assets.compile = true 

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

    # Specifies the header that your server uses for sending files. 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
    # config.force_ssl = true 

    # Set to :debug to see everything in the log. 
    config.log_level = :info 

    # Prepend all log lines with the following tags. 
    # config.log_tags = [ :subdomain, :uuid ] 

    # Use a different logger for distributed setups. 
    # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 

    # Use a different cache store in production. 
    # config.cache_store = :mem_cache_store 

    # Enable serving of images, stylesheets, and JavaScripts from an asset server. 
    # config.action_controller.asset_host = "http://assets.example.com" 

    # Precompile additional assets. 
    # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 
    # config.assets.precompile += %w(search.js) 

    # Ignore bad email addresses and do not raise email delivery errors. 
    # Set this to true and configure the email server for immediate delivery to raise delivery errors. 
    # config.action_mailer.raise_delivery_errors = false 

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
    # the I18n.default_locale when a translation can not be found). 
    config.i18n.fallbacks = true 

    # Send deprecation notices to registered listeners. 
    config.active_support.deprecation = :notify 

    # Disable automatic flushing of the log to improve performance. 
    # config.autoflush_log = false 

    # Use default logging formatter so that PID and timestamp are not suppressed. 
    config.log_formatter = ::Logger::Formatter.new 
end 

उत्तर

6

मैं मिलती-जुलती मुद्दा मिल गया है।

यहाँ IMAGE_TAG लिंक्स के लिए मेरा समाधान है:

<%= image_tag asset_path("combat_elephant.png") %> 
<%= link_to (image_tag asset_path("puskay_pivka_zahvatyat.png")), "/path" %> 

इसके अलावा, मैं स्थिर संपत्ति की सेवा के लिए nginx उपयोग कर रहा हूँ, इसलिए मैं है config: IMAGE_TAG '/pic.ext' इस तरह के बजाय) IMAGE_TAG asset_path (का उपयोग .serve_static_assets = झूठे और config.assets.compile = सच

आशा व्यक्त की कि

+0

अच्छा! मैंने रेल 3.2.13 से रेल 4 तक स्विच किया, और रेल की शैली में टैग से बदलकर चीजों को काम किया। – Jack

+0

पहला मुद्दा थाम्सफॉररेल मणि बग था। फिक्स्ड फोर्क मेरे जिथब पर है। – jirikolarik

+1

रेल 4 चाहिए सिर्फ image_tag ("logo.png") के साथ काम नहीं करना चाहिए ??? – Rubytastic

9

आप को यहां बताए गए ये समस्या हो रही हो सकता है में मदद करता है: No route matches [GET] /assets

असल में, यदि आप अपने ऐप का परीक्षण करने के लिए रेल सर्वर का उपयोग कर रहे हैं, तो आपकी प्रीकंपील्ड संपत्ति डिफ़ॉल्ट रूप से कार्य नहीं की जाएगी। रेलों की सेवा करने के लिए वेब सर्वर (अपाचे, nginx, आदि) की अपेक्षा करता है। आपको कॉन्फ़िगर/वातावरण/production.rb में परिवर्तन करने की आवश्यकता है और true_static_assets को सत्य पर सेट करना होगा।

+1

लेकिन मैं यह कैसे कर सकता हूं? मैं अपाचे को कैसे/संपत्ति फ़ोल्डर से फाइलों की सेवा करने के लिए बता सकता हूं? – oyatek

संबंधित मुद्दे