vendredi 22 septembre 2017

OmniAuth with Device, Rails 5 error -"Could not find devise mapping for path"

I have this routes:

Rails.application.routes.draw do
    root to: 'home#index'
    devise_for :user, :path => '', 
    :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "registration" }

    match '/auth/:provider/callback', to: 'users/omniauth_callbacks#create', via: [:post, :get]
end

When I try to login, it goes to Twitter page and redirect back, but I see this error:

Could not find devise mapping for path "/auth/twitter/callback?oauth_token=..This may happen for two reasons: 1) You forgot to wrap your route inside the scope block. For example: devise_scope :user do get "/some/route" => "some_devise_controller" end 2) You are testing a Devise controller bypassing the router. If so, you can explicitly tell Devise which mapping to use: @request.env["devise.mapping"] = Devise.mappings[:user]

I changed default URLs for login, register and logout with Device. I am using 1 method for all providers. How to set routes to fix this error ?

Aucun commentaire:

Enregistrer un commentaire