我已经在服务器上部署了我的rails应用程序,但是当我尝试预编译资产时它也显示错误,每当我尝试在生产环境中运行我的服务器时它会抛出 ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css"):
每次都有错误。由于此问题建议here预先整理您的资产。但我仍然得到这个错误:
deploy@TTP:/srv/ttp$ RAILS_ENV=production bundle exec rake assets:precompile
I, [2015-06-17T07:40:19.366868 #14706] INFO -- : Writing /srv/ttp/public/assets/application-b70462741c5220649c0fae6b371f8bb0db1f69df9980817ca94517d13ec3e90e.js
I, [2015-06-17T07:40:27.543196 #14706] INFO -- : Writing /srv/ttp/public/assets/application-8fad86d02acda5dc8d383ef570b85dc9991784b53d994dc532ed69632be450db.css
rake aborted!
Errno::EPERM: Operation not permitted @ sys_fail2 - (/srv/ttp/public/assets/.sprockets-manifest-81cc84ad6ecbcbede263dab4150a3105.json.11450760.14706.293714, /srv/ttp/public/assets/.sprockets-manifest-81cc84ad6ecbcbede263dab4150a3105.json)
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-3.0.1/lib/sprockets/path_utils.rb:277:in `atomic_write'
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-3.0.1/lib/sprockets/manifest.rb:261:in `save'
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-3.0.1/lib/sprockets/manifest.rb:183:in `compile'
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-3.0.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/usr/local/rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
日志/ production.log
I, [2015-05-12T12:36:11.882313 #26372] INFO -- : Started GET "/" for 1.22.20.40 at 2015-05-12 12:36:11 -0400
I, [2015-05-12T12:36:11.895927 #26372] INFO -- : Processing by RecordsController#index as HTML
I, [2015-05-12T12:36:11.908520 #26372] INFO -- : Rendered records/index.html.erb within layouts/application (3.1ms)
I, [2015-05-12T12:36:11.926940 #26372] INFO -- : Completed 200 OK in 31ms (Views: 28.8ms | ActiveRecord: 0.0ms)
I, [2015-05-12T12:36:12.307845 #26372] INFO -- : Started GET "/stylesheets/application.css" for 1.22.20.40 at 2015-05-12 12:36:12 -0400
F, [2015-05-12T12:36:12.309134 #26372] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css"):
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
puma (2.11.2) lib/puma/server.rb:507:in `handle_request'
puma (2.11.2) lib/puma/server.rb:375:in `process_client'
puma (2.11.2) lib/puma/server.rb:262:in `block in run'
puma (2.11.2) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.2) lib/puma/thread_pool.rb:104:in `block in spawn_thread'
答案 0 :(得分:1)
问题是你编译的断言保存在这里
/assets/application-b70462741c5220649c0fae6b371f8bb0db1f69df9980817ca94517d13ec3e90e.js
但您的客户尝试获取
/stylesheets/application.css
您应该更改客户端上CSS断言的路径。 如果您混淆,请将模板发布到设置CSS文件的位置。
答案 1 :(得分:0)
通过删除我的releases /目录中的所有目录并再次运行cap deploy,我修复了同样的错误。
无法解释,但我认为这可能有助于某人!