2016-06-11 66 views
0

我剛剛在我的Rails應用程序的生產模式中解決了一些數據庫問題,現在我無法獲取任何資產。這裏是production.log部分:我無法讓資產在Rails應用程序中工作

I, [2016-06-11T10:26:14.368556 #4807] INFO -- : Started GET "/assets/application-dcd31064dda15c4420c78914a108b57fe4a17ea71a20e180b4d51e1f12c45c7a.js" for 127.0.0.1 at 2016-06-11 10:26:14 +0200 
F, [2016-06-11T10:26:14.375224 #4807] FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/assets/application-dcd31064dda15c4420c78914a108b57fe4a17ea71a20e180b4d51e1f12c45c7a.js"): 
    actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
    railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app' 
    railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call' 
    activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged' 
    activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged' 
    activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged' 
    railties (4.2.6) lib/rails/rack/logger.rb:20:in `call' 
    actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call' 
    rack (1.6.4) lib/rack/methodoverride.rb:22:in `call' 
    rack (1.6.4) lib/rack/runtime.rb:18:in `call' 
    activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 
    rack (1.6.4) lib/rack/sendfile.rb:113:in `call' 
    railties (4.2.6) lib/rails/engine.rb:518:in `call' 
    railties (4.2.6) lib/rails/application.rb:165:in `call' 
    rack (1.6.4) lib/rack/lock.rb:17:in `call' 
    rack (1.6.4) lib/rack/content_length.rb:15:in `call' 
    rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service' 
    /home/nikola/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service' 
    /home/nikola/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run' 
    /home/nikola/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread' 

我有app/assets/javascript/application.jsapp/assets/stylesheet/application.scss因爲引導的。我嘗試了預編譯生產環境的資產,但仍然沒有任何結果。

應用程序/資產/樣式表/ aplication.scss

/* 
* 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 any plugin's vendor/assets/stylesheets directory 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 bottom of the 
* compiled file so the styles you add here take precedence over styles defined in any styles 
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new 
* file per style scope. 
* 
*= require styles 
*/ 

@import "bootstrap-sprockets"; 
@import "bootstrap"; 
@font-face{ 
font-family:'Glyphicons Halflings'; 
src: font-url("bootstrap/glyphicons-halflings-regular.eot"); 
src: font-url("bootstrap/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), 
font-url("bootstrap/glyphicons-halflings-regular.woff") format("woff"), 
font-url("bootstrap/glyphicons-halflings-regular.ttf") format("truetype"), 
font-url("bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg") 
} 
+0

你在/ public目錄下有預編譯資源嗎? – kunashir

+0

@kunashir是的,它們是預編譯的。 – Nikola

回答

0

問題就解決了 - 我不得不改變這一行:

config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 

config.serve_static_files = true 

config/environments/production.rb/public目錄提供靜態文件。

相關問題