“Could not find a valid mapping for #” only on second and successive tests

后端 未结 9 1983
花落未央
花落未央 2020-12-28 13:28

I\'m trying to write a request test that asserts that the proper links appear on the application layout depending in whether a user is logged in or out. FWIW, I\'m using Dev

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 14:10

    I had this error in my routes file because I had an API endpoint that I wanted to allow users to reset their passwords from, but I wanted the users to actually do the password change on the web view, which wasn't namespaced under /api

    This is how I fixed the routes to make it work:

    CoolApp::Application.routes.draw do
      namespace :api, defaults: { format: :json } do
        devise_scope :users do
          post 'users/passwords', to: 'passwords#create'
        end
    
        resources :users, only: [:create, :update]
      end
    
      devise_for :users
    
      root to: 'high_voltage/pages#show', id: 'home'
    end
    

提交回复
热议问题