设计没有匹配会话/用户的路由?

发布于 2024-11-30 20:15:07 字数 4680 浏览 0 评论 0原文

我使用我的 Rails 3 项目设置 Devise 身份验证,当我单击登录按钮时,它会显示:

No route matches "/session/user"

无论我是否使用有效的凭据。

这是我的设计表单(我没有从默认值中进行编辑)

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:novalidate => 'novalidate'}) do |f| %>

任何建议?

更新

Routes.rb

SpecimenTracker::Application.routes.draw do
  devise_for :users

  resources :users
resources :results
  resources :session
match "/results/show" => "results#show"
match "/messages/show" => "messages#show"
match "/login/index" => "login#index"
match "/login/authenticate" => "login#authenticate"
  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
get 'home/index'
root :to => 'home#index'
  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing the them or commenting them out if you're using named routes and resources.
end

Gemfile(仅是我为设计添加的部分)

gem 'net-ldap'

gem "devise", "~> 1.4"
gem "devise_ldap_authenticatable"


gem 'hpricot'
gem 'ruby_parser'

rake 路由的输出(底部的所有会话都来自我尝试使用但后来转储的旧身份验证系统。不应该影响任何东西..对?)

  new_user_session GET    /users/sign_in(.:format)      {:controller=>"devise/sessions", :action=>"new"}
        user_session POST   /users/sign_in(.:format)      {:controller=>"devise/sessions", :action=>"create"}
destroy_user_session DELETE /users/sign_out(.:format)     {:controller=>"devise/sessions", :action=>"destroy"}
               users GET    /users(.:format)              {:controller=>"users", :action=>"index"}
                     POST   /users(.:format)              {:controller=>"users", :action=>"create"}
            new_user GET    /users/new(.:format)          {:controller=>"users", :action=>"new"}
           edit_user GET    /users/:id/edit(.:format)     {:controller=>"users", :action=>"edit"}
                user GET    /users/:id(.:format)          {:controller=>"users", :action=>"show"}
                     PUT    /users/:id(.:format)          {:controller=>"users", :action=>"update"}
                     DELETE /users/:id(.:format)          {:controller=>"users", :action=>"destroy"}
             results GET    /results(.:format)            {:controller=>"results", :action=>"index"}
                     POST   /results(.:format)            {:controller=>"results", :action=>"create"}
          new_result GET    /results/new(.:format)        {:controller=>"results", :action=>"new"}
         edit_result GET    /results/:id/edit(.:format)   {:controller=>"results", :action=>"edit"}
              result GET    /results/:id(.:format)        {:controller=>"results", :action=>"show"}
                     PUT    /results/:id(.:format)        {:controller=>"results", :action=>"update"}
                     DELETE /results/:id(.:format)        {:controller=>"results", :action=>"destroy"}
       session_index GET    /session(.:format)            {:controller=>"session", :action=>"index"}
                     POST   /session(.:format)            {:controller=>"session", :action=>"create"}
         new_session GET    /session/new(.:format)        {:controller=>"session", :action=>"new"}
        edit_session GET    /session/:id/edit(.:format)   {:controller=>"session", :action=>"edit"}
             session GET    /session/:id(.:format)        {:controller=>"session", :action=>"show"}
                     PUT    /session/:id(.:format)        {:controller=>"session", :action=>"update"}
                     DELETE /session/:id(.:format)        {:controller=>"session", :action=>"destroy"}
        results_show        /results/show(.:format)       {:controller=>"results", :action=>"show"}
       messages_show        /messages/show(.:format)      {:controller=>"messages", :action=>"show"}
         login_index        /login/index(.:format)        {:controller=>"login", :action=>"index"}
  login_authenticate        /login/authenticate(.:format) {:controller=>"login", :action=>"authenticate"}
          home_index GET    /home/index(.:format)         {:controller=>"home", :action=>"index"}
                root        /(.:format)                   {:controller=>"home", :action=>"index"}

Im setting up Devise authentication with my rails 3 project and when i click the sign in button, it displays :

No route matches "/session/user"

No matter if I use valid credentials or not..

Heres my form for devise (which i did NOT edit from the defaults)

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:novalidate => 'novalidate'}) do |f| %>

Any suggestions?

UPDATE

Routes.rb

SpecimenTracker::Application.routes.draw do
  devise_for :users

  resources :users
resources :results
  resources :session
match "/results/show" => "results#show"
match "/messages/show" => "messages#show"
match "/login/index" => "login#index"
match "/login/authenticate" => "login#authenticate"
  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
get 'home/index'
root :to => 'home#index'
  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing the them or commenting them out if you're using named routes and resources.
end

Gemfile (only parts i added for devise)

gem 'net-ldap'

gem "devise", "~> 1.4"
gem "devise_ldap_authenticatable"


gem 'hpricot'
gem 'ruby_parser'

Output of rake routes (All the session on the bottom are from an old authentication system i tried using but then dumped. Shouldnt affect anything.. right? )

  new_user_session GET    /users/sign_in(.:format)      {:controller=>"devise/sessions", :action=>"new"}
        user_session POST   /users/sign_in(.:format)      {:controller=>"devise/sessions", :action=>"create"}
destroy_user_session DELETE /users/sign_out(.:format)     {:controller=>"devise/sessions", :action=>"destroy"}
               users GET    /users(.:format)              {:controller=>"users", :action=>"index"}
                     POST   /users(.:format)              {:controller=>"users", :action=>"create"}
            new_user GET    /users/new(.:format)          {:controller=>"users", :action=>"new"}
           edit_user GET    /users/:id/edit(.:format)     {:controller=>"users", :action=>"edit"}
                user GET    /users/:id(.:format)          {:controller=>"users", :action=>"show"}
                     PUT    /users/:id(.:format)          {:controller=>"users", :action=>"update"}
                     DELETE /users/:id(.:format)          {:controller=>"users", :action=>"destroy"}
             results GET    /results(.:format)            {:controller=>"results", :action=>"index"}
                     POST   /results(.:format)            {:controller=>"results", :action=>"create"}
          new_result GET    /results/new(.:format)        {:controller=>"results", :action=>"new"}
         edit_result GET    /results/:id/edit(.:format)   {:controller=>"results", :action=>"edit"}
              result GET    /results/:id(.:format)        {:controller=>"results", :action=>"show"}
                     PUT    /results/:id(.:format)        {:controller=>"results", :action=>"update"}
                     DELETE /results/:id(.:format)        {:controller=>"results", :action=>"destroy"}
       session_index GET    /session(.:format)            {:controller=>"session", :action=>"index"}
                     POST   /session(.:format)            {:controller=>"session", :action=>"create"}
         new_session GET    /session/new(.:format)        {:controller=>"session", :action=>"new"}
        edit_session GET    /session/:id/edit(.:format)   {:controller=>"session", :action=>"edit"}
             session GET    /session/:id(.:format)        {:controller=>"session", :action=>"show"}
                     PUT    /session/:id(.:format)        {:controller=>"session", :action=>"update"}
                     DELETE /session/:id(.:format)        {:controller=>"session", :action=>"destroy"}
        results_show        /results/show(.:format)       {:controller=>"results", :action=>"show"}
       messages_show        /messages/show(.:format)      {:controller=>"messages", :action=>"show"}
         login_index        /login/index(.:format)        {:controller=>"login", :action=>"index"}
  login_authenticate        /login/authenticate(.:format) {:controller=>"login", :action=>"authenticate"}
          home_index GET    /home/index(.:format)         {:controller=>"home", :action=>"index"}
                root        /(.:format)                   {:controller=>"home", :action=>"index"}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请恋爱 2024-12-07 20:15:07

检查你的config/routes.rb,是否有一条线路用于设计?
如果没有,您可能需要运行

rails generate devise_install

And

rails generate devise User

Check your config/routes.rb, is there a line for devise?
If not, you may want to run

rails generate devise_install

And

rails generate devise User
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文