我正在运行一个带有nginx和乘客的生产服务器,到目前为止一直很好,直到我加载资产。首先我注意到我得到了这个错误(其中一些实际上是针对没有加载-images,js和css的各种资产)。
I, [2013-09-09T02:14:03.566777 #16843] INFO -- : Started GET "/stylesheets/style-responsive.css" for 137.XXX.XXX.228 at 2013-09-09 02:14:03 +0000
F, [2013-09-09T02:14:03.568269 #16843] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/stylesheets/style-responsive.css"):
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'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
passenger (4.0.16) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
passenger (4.0.16) lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
passenger (4.0.16) lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
passenger (4.0.16) lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
我对堆栈溢出做了一些研究,并意识到我需要预编译资产,这样做我在预编译期间遇到了另一个错误(rake assets:precompile
),错误如下:
(in /var/www/rails_apps/binaryhustle)
rake aborted!
/var/www/rails_apps/binaryhustle/app/assets/javascripts/application.js has already been required
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:392:in `circular_call_protection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:373:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:105:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:16:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:374:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:374:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:373:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:105:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/processed_asset.rb:16:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:374:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:374:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:373:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:377:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:377:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:93:in `build_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/base.rb:287:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/index.rb:61:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:257:in `benchmark'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:210:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:119:in `block in compile'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/sprockets/manifest.rb:118:in `compile'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-2.10.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
ubuntu@ip-172-31-20-120:/var/www/rails_apps/binaryhustle/app$
虽然图像资产似乎已被编译(我的公共/资源文件夹中有许多这样的文件:background-a24d0e733ba865da3290423b79329eb4.png
,但编译的图像也会收到get错误(但这可能只是由于我的图片标签未正确设置 - 这仍然无法解释为什么css和js无法正常工作,因为链接格式正确,如下所示:
<%= stylesheet_link_tag "bootstrap.min", "style", "style-responsive", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "bootstrap.min", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
不确定从哪里开始!提前谢谢。