我刚刚在我的Rails应用程序的生产模式中修复了数据库的一些问题,现在我无法获得任何资产。这是production.log的一部分:
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'
由于Bootstrap,我有app/assets/javascript/application.js
和app/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 :(得分:0)
问题解决了 - 我只需改变这一行:
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
要
config.serve_static_files = true
在 config / environments / production.rb 中提供来自 / public 目录的静态文件。