Rails devize help routing error No match for "/ sessions / user" routes

When I enter my page, I automatically go to the route: http: // localhost: 3000 / sessions / user

And I get this error:

Routing Error No route matches "/sessions/user" 

I created a controller called session_controller.rb in the users folder, here it is:

 class Users::SessionsController < Devise::SessionsController def new redirect_to root_url, :notice => "You have been logged out." end def create user = User.authenticate(params[:login], params[:encrypted_password]) if user session[:user_id] = user.id redirect_to root_url, :notice => "Logged in successfully." else flash.now[:alert] = "Invalid login or password." render :action => 'new' end end def destroy session[:user_id] = nil redirect_to root_url, :notice => "You have been logged out." end end 

My route file:

 Densidste::Application.routes.draw do match 'user/edit' => 'users#edit', :as => :edit_current_user devise_for :users, :controllers => { :sessions => "users/sessions" } do get "login", :to => "devise/sessions#new" get "opret", :to => 'users/users#new' get "logud", :to => 'users/users#destroy' end resources :sessions resources :users devise_for :users, :controllers => { :sessions => "users/sessions" } resources :aktivs resources :taggingposts resources :tags resources :kommentares resources :posts end 
+4
source share
3 answers

(An old question, but I ran into the same problem when setting up Devise, so hope this helps others)

Removing resources :sessions from the routes file should fix the problem.

+7
source

For those who are experiencing this problem with Devise 2.0 and Rails 3.2.1 , and have checked all the comments made by @Micah Alcorn, but still having a problem - restart the web server. Worked for me.

+2
source

You do not have root_url . It still points to static public / index.html. (edited by Ryan Bigg)

devise_for :users specified twice.

resources :users not required unless you have a RESTful controller to handle destruction and indexing actions outside of development.

Do you actually have a β€œcustom” controller for this first editing action? This should probably be in the user Users::RegistrationsController < Devise::RegistrationsController .

0
source

All Articles