路由错误 - 救援布局 + 没有路由匹配 [GET]“/sockjs-node/info”

Routing Error - rescue Layout + No route matches [GET] "/sockjs-node/info"

我的 Rails 5 应用出现路由错误,渲染或重定向页面需要几秒钟。

日志:

Started GET "/sockjs-node/info?t=1473196651723" for ::1 at 2016-09-06 22:17:31 +0100

ActionController::RoutingError (No route matches [GET] "/sockjs-node/info"):

actionpack (5.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
actionpack (5.0.0) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.0.0) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
railties (5.0.0) lib/rails/engine.rb:522:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
  Rendering /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout
  Rendered collection of /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/routes/_route.html.erb [37 times] (506.0ms)
  Rendering /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.2ms)
  Rendered /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.7ms)
  Rendering /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (2.2ms)
  Rendered /Users/Dudis/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (17531.2ms)

路线:

Rails.application.routes.draw do
  root 'menu#home'   get 'menus/pricing' => 'menu#pricing', path: 'pricing'   get 'menus/features'=> 'menu#features', path: 'features'
  get 'dashboards/index'
  devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks'}
  mount ActionCable.server => '/cable'
  resources :users
  resources :checkers, only: [:new, :create, :show]   resources :newsletters, only: [:new, :create]
end

佣金路线:

                               Prefix Verb     URI Pattern                                  Controller#Action
                     dashboards_index GET      /dashboards/index(.:format)                  dashboards#index
                     new_user_session GET      /users/sign_in(.:format)                     devise/sessions#new
                         user_session POST     /users/sign_in(.:format)                     devise/sessions#create
                 destroy_user_session DELETE   /users/sign_out(.:format)                    devise/sessions#destroy
     user_facebook_omniauth_authorize GET|POST /users/auth/facebook(.:format)               users/omniauth_callbacks#passthru
      user_facebook_omniauth_callback GET|POST /users/auth/facebook/callback(.:format)      users/omniauth_callbacks#facebook
user_google_oauth2_omniauth_authorize GET|POST /users/auth/google_oauth2(.:format)          users/omniauth_callbacks#passthru
 user_google_oauth2_omniauth_callback GET|POST /users/auth/google_oauth2/callback(.:format) users/omniauth_callbacks#google_oauth2
                        user_password POST     /users/password(.:format)                    devise/passwords#create
                    new_user_password GET      /users/password/new(.:format)                devise/passwords#new
                   edit_user_password GET      /users/password/edit(.:format)               devise/passwords#edit
                                      PATCH    /users/password(.:format)                    devise/passwords#update
                                      PUT      /users/password(.:format)                    devise/passwords#update
             cancel_user_registration GET      /users/cancel(.:format)                      devise/registrations#cancel
                    user_registration POST     /users(.:format)                             devise/registrations#create
                new_user_registration GET      /users/sign_up(.:format)                     devise/registrations#new
               edit_user_registration GET      /users/edit(.:format)                        devise/registrations#edit
                                      PATCH    /users(.:format)                             devise/registrations#update
                                      PUT      /users(.:format)                             devise/registrations#update
                                      DELETE   /users(.:format)                             devise/registrations#destroy
                                               /cable                                       #<ActionCable::Server::Base:0x007ff348689c80 @mutex=#<Monitor:0x007ff348689c58 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007ff348689c08>>, @pubsub=nil, @worker_pool=nil, @event_loop=nil, @remote_connections=nil>
                                 root GET      /                                            menu#home
                        menus_pricing GET      /pricing(.:format)                           menu#pricing
                       menus_features GET      /features(.:format)                          menu#features
                                users GET      /users(.:format)                             users#index
                                      POST     /users(.:format)                             users#create
                             new_user GET      /users/new(.:format)                         users#new
                            edit_user GET      /users/:id/edit(.:format)                    users#edit
                                 user GET      /users/:id(.:format)                         users#show
                                      PATCH    /users/:id(.:format)                         users#update
                                      PUT      /users/:id(.:format)                         users#update
                                      DELETE   /users/:id(.:format)                         users#destroy
                             checkers POST     /checkers(.:format)                          checkers#create
                          new_checker GET      /checkers/new(.:format)                      checkers#new
                              checker GET      /checkers/:id(.:format)                      checkers#show
                          newsletters POST     /newsletters(.:format)                       newsletters#create
                       new_newsletter GET      /newsletters/new(.:format)                   newsletters#new

我如何调试它以及什么是 sockjs-node/info?

我最近 运行 也喜欢这个。它是在我在 localhost:3000.

上构建 rails5 api 之后开始的

在我开始处理另一个使用 localhost:3000 的不相关项目后,我开始收到此错误。

为了补救我只是暂时指定了另一个端口rails server -p 8000

除此之外,我还没有想出如何解决它。

sockjs-nodewebpack-dev-server 使用。

为避免路由错误,请确保 Webpack 使用的端口与默认使用的 Rails 服务器 Puma 使用的端口不同。即使在不同的端口上,资产仍然可用。

对于webpack-dev-server,勾选config/webpacker.yml

dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    hmr: false

如果使用默认 rails server,请检查 config/puma.rb :

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port        ENV.fetch("PORT") { 3000 }