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

时间:2016-09-06 21:25:41

标签: ruby-on-rails ruby-on-rails-5

我在Rails 5应用中遇到路由错误,渲染或重定向页面需要几秒钟。

  • ActionController :: RoutingError(没有路由匹配[GET]" / sockjs-node / info")
  • 5.0.0 / lib / action_dispatch / middleware / templates / routes / _route.html.erb [37次](506.0ms)
  • 5.0.0 / lib / action_dispatch / middleware / templates / rescues / routing_error.html.erb救援/布局(17531.2ms)

日志:

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?

2 个答案:

答案 0 :(得分:2)

我最近也碰到了这个。它是在我在localhost:3000上构建rails5 api之后开始的。

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

要解决此问题,我暂时只指定了另一个端口rails server -p 8000

除此之外,我还没弄清楚如何修复它。

答案 1 :(得分:0)

from discord.ext import commands class Cog01(commands.Cog): def __int__(self, client): self.client = client @commands.Cog.listener() async def on_ready(self): for guild in self.client.guilds: await guild.system_channel.send("I'm ready to go!") def setup(client): client.add_cog(Cog01(client)) sockjs-node使用。

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

对于webpack-dev-server,请检查webpack-dev-server

config/webpacker.yml

如果使用默认的dev_server: https: false host: localhost port: 3035 public: localhost:3035 hmr: false ,请选中rails server

config/puma.rb