没有路由匹配service-worker.js

时间:2015-07-21 17:53:23

标签: ruby-on-rails ruby routing routes

我生成了rails应用程序,我收到了这个消息。我不知道service-worker.js是什么,但我认为它可以捆绑一些默认的gem?

Started GET "/service-worker.js" for 127.0.0.1 at 2015-07-21 19:48:33 +0200

ActionController::RoutingError (No route matches [GET] "/service-worker.js"):
  actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.3) 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.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.3) lib/rails/engine.rb:518:in `call'
  railties (4.2.3) 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/emkacf/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /home/emkacf/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /home/emkacf/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

3 个答案:

答案 0 :(得分:0)

我认为这是来自另一个使用webworkers的应用程序。如果您使用的是Firefox,请转到菜单> web开发人员>服务工作者和从那里取消注册webworker(这是一种方法)。如果需要,另一个应用程序将再次注册它。

答案 1 :(得分:0)

这是来自客户端的,它来自已在浏览器中注册的服务人员。

打开DevTools并在控制台中运行navigator.serviceWorker.getRegistration().then(r => r.unregister())以将其禁用。

答案 2 :(得分:0)

我通过this gem解决了相同的问题。

1)将gem 'serviceworker-rails'添加到 Gemfile

2)在控制台中运行bundle install

3)在控制台中运行rails g serviceworker:install

4)将match '/offline.html'字符串添加到 config / initializers / serviceworker.rb

5)创建文件(即使为空也足够) public / offline.html

就这样。完成这些步骤后,错误消息消失了。