ruby-on-rails – Rails设计帮助路由错误没有路由匹配“/ sessions / user”

当我登录我的页面时,我自动转到路线:http://localhost:3000/sessions/user

我收到这个错误:

Routing Error

No route matches "/sessions/user"

我在users文件夹中创建了一个名为sessions_controller.rb的控制器,它是:

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

我的路线档案:

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
最佳答案
(老问题,但我在设置Devise时遇到了同样的问题,所以希望这有助于其他人)

删除资源:路由文件中的会话应该可以解决问题.

转载注明原文:ruby-on-rails – Rails设计帮助路由错误没有路由匹配“/ sessions / user” - 代码日志