2016-06-11 138 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目录提供静态文件。

相关问题