1
votes
Could not find devise mapping for path "/". 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 am getting this error when I try to go here

http://localhost:3000/

And here are the routes

  devise_scope :user do
     get '/users/sign_in' => 'devise/sessions#new', as: :new_user_session
     post   '/users/sign_in'  => 'devise/sessions#create',  as: :user_session
     delete '/users/sign_out' => 'devise/sessions#destroy', as: :destroy_user_session

     post  '/users/password'  => 'devise/passwords#create', as: :user_password
     put   '/users/password'  => 'devise/passwords#update', as: nil
     patch '/users/password'  => 'devise/passwords#update', as: nil
     authenticated :user do
        root :to => 'home#index', as: :authenticated_root
     end
     unauthenticated :user do
        root :to => 'devise/sessions#new', as: :unauthenticated_root
     end

  end

This set up was working earlier so I don't know why it is suddenly failing. Details about my setup (from memory): I did

bundle install

with devise as a gem

rails g devise user

rails generate devise:views

I added this line in development.rb

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

Also, I am using rails 4.2.0.beta1 and devise 3.3.0 pulling from (git => 'https://github.com/plataformatec/devise.git', :branch => 'lm-rails-4-2')

1

1 Answers

0
votes

Try writing routes in scope block.

devise_scope :user do
    # write all your routes inside this block
end

You can find more about scope here

https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes