Could not find devise mapping for path “/sessions/user” devise log in error

前端 未结 5 2034
名媛妹妹
名媛妹妹 2021-02-19 04:43

Very frustrating for the last few days.

I have a rails app with Devise installed where I generated a new User model and I generated Devise views as well.

This h

5条回答
  •  旧巷少年郎
    2021-02-19 05:19

    in your routes.rb file, try wrapping your routes inside the scope block as the error message suggests. Here is an example:

    devise_scope :user do
       get "signup", to: "devise/registrations#new"
       get "login", to: "devise/sessions#new"
       get "logout", to: "devise/sessions#destroy"
    end
    

    This will give you nicely named routes.

    And by the way, if you are using Rails 4, get rid of the match method. you need to specify the HTTP verb.


    OBSOLETE old answer:

    (Below is the old obsolete version of the code, shown for reference. Use the code above.)

    devise_for :users, path_names: { sign_in: 'login', sign_out: 'logout', sign_up: 'signup' }
    

    AND

    match '/sessions/user', to: 'devise/sessions#create', via: :post
    

提交回复
热议问题