2013-06-13 26 views
9

में लोड नहीं हो रहा है मैंने अपने ऐप को हरोकू में तैनात किया है, लेकिन केवल संपत्तियां \ छवियां लोड हो रही हैं। सीएसएस फाइलें (विशेष रूप से वह जिसमें 9 0% सीएसएस, custom.css शामिल है) लोड नहीं हो रहे हैं। मैंने स्थानीय रूप से परिसंपत्तियों का प्रीकंपल किया और उन्हें बिना किसी किस्मत के हेरोकू में धकेल दिया। केवल छवियां लोड हो रही हैं, कस्टम.css फ़ाइल नहीं।सीएसएस हेरोोकू

शुरू किया 2013-06-13 02:42:09 +0000 पर 77.777.777.77 के लिए GET "https://stackoverflow.com/users/css/parallax-slider.css":

मैं Heroku लॉग में एक दिलचस्प त्रुटि दिखाई देती किया 2013-06-13T02: 42: ०९.०१६८६४ + 00: 00 ऐप्लिकेशन [web.1]: ActionController :: RoutingError (कोई मार्ग मैचों [प्राप्त] "https://stackoverflow.com/users/css/parallax-slider.css"):

यह मेरे उपयोगकर्ताओं नियंत्रक फ़ोल्डर में सीएसएस की तलाश क्यों कर रहा है? क्या यह ऐप custom.css फ़ाइल लोड नहीं कर सकता है?

production.rb

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

    # Code is not reloaded between requests 
    config.cache_classes = true 

    # Full error reports are disabled and caching is turned on 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # Disable Rails's static asset server (Apache or nginx will already do this) 
    config.serve_static_assets = false 

    # Compress JavaScripts and CSS 
    config.assets.compress = false 

    # Don't fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = false 

    # Generate digests for assets URLs 
    config.assets.digest = true 

    # Defaults to nil and saved in location specified by config.assets.prefix 
    # config.assets.manifest = YOUR_PATH 

    # 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 

    # See everything in the log (default is :info) 
    # config.log_level = :debug 

    # 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 are already added) 
    config.assets.precompile += %w(custom.css hover.css users.css works.css styleie9.css) 

    # Disable delivery errors, bad email addresses will be ignored 
    # config.action_mailer.raise_delivery_errors = false 

    # Enable threaded mode 
    # config.threadsafe! 

    # 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 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    # config.active_record.auto_explain_threshold_in_seconds = 0.5 

    #TODO: Edit devise mailer config 
    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
end 

application.rb

require File.expand_path('../boot', __FILE__) 

# Pick the frameworks you want: 
require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "active_resource/railtie" 
require "sprockets/railtie" 
# require "rails/test_unit/railtie" 

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    #Bundler.require(:default, :assets, Rails.env) 
end 

module App 
    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. 

    # Custom directories with classes and modules you want to be autoloadable. 
    # config.autoload_paths += %W(#{config.root}/extras) 

    # Only load the plugins named here, in the order given (default is alphabetical). 
    # :all can be used as a placeholder for all plugins not explicitly named. 
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 

    # Activate observers that should always be running. 
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 

    # 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 

    # Configure the default encoding used in templates for Ruby 1.9. 
    config.encoding = "utf-8" 

    # Configure sensitive parameters which will be filtered from the log file. 
    config.filter_parameters += [:password] 

    # Enable escaping HTML in JSON. 
    config.active_support.escape_html_entities_in_json = true 

    # Use SQL instead of Active Record's schema dumper when creating the database. 
    # This is necessary if your schema can't be completely dumped by the schema dumper, 
    # like if you have constraints or database-specific column types 
    # config.active_record.schema_format = :sql 

    # Enforce whitelist mode for mass assignment. 
    # This will create an empty whitelist of attributes available for mass-assignment for all models 
    # in your app. As such, your models will need to explicitly whitelist or blacklist accessible 
    # parameters by using an attr_accessible or attr_protected declaration. 
    config.active_record.whitelist_attributes = true 

    # Enable the asset pipeline 
    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 

    #Required for Heroku deployment 
    config.assets.initialize_on_precompile = false 

    #get precompilation working on heroku: 
    #config.assets.initialize_on_precompile = true 

    config.serve_static_assets = false 

    #Add fonts for Bootstrap theme 
    config.assets.paths << Rails.root.join("app", "assets", "fonts") 

    #Prevent passwords from being written to logs 
    config.filter_parameters += [:password, :password_confirmation] 
    end 
end 

किसी भी मदद की बहुत सराहना की जाएगी। मैंने इस पर दो नींद की रात बिताई है और मैं पूरी तरह से स्टंप हूं।

धन्यवाद! बी

संपादित करें 1

application.css:

/* 
* This is a manifest file that'll be compiled into application.css, which will include all the files 
* listed below. 
* 
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 
* 
* You're free to add application-wide styles to this file and they'll appear at the top of the 
* compiled file, but it's generally better to create a new file per style scope. 
* 
*= require_self 
*= require_tree . 
*/ 

.pagination { 
    background: white; 
    cursor: default; 
    margin-top: 20px; 
    a, span, em { 
    padding: 0.2em 0.5em; 
    display: block; 
    float: left; 
    margin-right: 1px; 
    } 

मार्गों:

authenticated :user do 
    root :to => 'activities#index' 
    end 
    root :to => "home#index" 
    devise_for :users, :controllers => { :registrations => "registrations" } 
    resources :users do 
    member do 
     get :following, :followers, :posts, :comments, :activities 
    end 
    end 
    resources :works do 
    resources :comments 
    end 
    resources :relationships, only: [:create, :destroy] 
    resources :posts 
    resources :activities 
    resources :reposts 
    resources :comments do 
    member do 
     put :toggle_is_contribution 
    end 
    end 
    resources :explore 
end 
+1

क्या आप अपना आवेदन.css और मार्ग फ़ाइल पोस्ट कर सकते हैं? – pungoyal

+0

हाय ब्रूस कृपया मेरी पोस्ट का प्रयास करें यह काम करेगा धन्यवाद –

+0

अब तक सहायता के लिए धन्यवाद। मैंने आवेदन सीएसएस और मार्ग – winston

उत्तर

18

कृपया इस अपने production.rb

Pl में आने वाले बदलाव config.serve_static_assets = true बनाने मुझे पता है कि happen.hope यह काम होगा कम ..

धन्यवाद

+0

मदद राजा के लिए धन्यवाद। दुर्भाग्यवश इस मुद्दे को हल नहीं किया – winston

+0

क्या आपने गिट एड कॉन्फ़िगर/enviroements/उत्पादन द्वारा heroku में अपने उत्पादन.आरबी को धक्का दिया है।आरबी और गिट प्रतिबद्ध -एम "", गिट पुश हेरोकू मास्टर –

+0

हां, मैंने गिट एड, गिट प्रतिबद्ध, गिट पुश, और गिट पुश हेरोकू मास्टर को बदलने के बाद – winston

-1

कैसे और उस करने से (नया खाली पंक्ति को जोड़ना) application.css (.scss) में एक परिवर्तन कर के बारे में? ऐसा लगता है कि हेरोोकू तदनुसार diff फ़ाइलों और precompiles संपत्तियों की जांच कर रहा है। मुझे बस यह गलती से पता चला, इसलिए यदि आप मदद करते हैं तो आप कोशिश कर सकते हैं।

6

अद्यतन

*group :production, :staging do 
     gem 'rails_12factor' 
    end* 

के साथ अपने gemfile अपने बंडल स्थापित करें और धक्का Heroku को

Installing rails_serve_static_assets (0.0.1) 
    Installing rails_stdout_logging (0.0.1) 
    Installing rails_12factor (0.0.2) 

यह मुझे मदद करता है जब मैं एक ही समस्या थी।

+0

यादृच्छिक है लेकिन यह काम करता है। धन्यवाद –

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