没有路由匹配[GET] QUOT; /用户/ SIGN_OUT" [英] No route matches [GET] "/users/sign_out"

查看:128
本文介绍了没有路由匹配[GET] QUOT; /用户/ SIGN_OUT"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我实际的错误:无路由匹配[GET]/会员/ SIGN_OUT
因为大多数人都用用户我认为这将是更有利于具有的称号。无论如何,我是必不可少无法注销。我可以成功地修改我的会员资料。

我使用的设计1.4.2和Rails 3.1.0.rc4。另外,我已经产生了两个不同的色器件模型 - 一个叫成员,另一个叫管理员。我能注册并登录到他们两个(同时)通过手动导航到正确的URL路径(即本地主机:3000 /管理员/ sign_in /)。我按照此 RailsCast上制定创建了application.html.haml布局文件中的一些链接。我知道,这只是解决登入/ signout链接,的成员。

如果我点击signout链接我得到上述错误。出现这种情况,如果我手动导航要么signout URL(即本地主机:3000 /管理员/ SIGN_OUT /).

谁能告诉我为什么发生这种情况?下面是相关的各种文件。当然,我是一个新手...

耙路输出:

 Ĵ(film_repo)$耙路线
        new_member_session GET /members/sign_in(.:format){:行动=>中新:控制器=>中设计/会话}
            member_session POST /members/sign_in(.:format){:行动=>中创造,:控制器=>中设计/会话}
    destroy_member_session DELETE /members/sign_out(.:format){:行动=>中消灭,:控制器=>中设计/会话}
           member_password POST /members/password(.:format){:行动=>中创造,:控制器=>中设计/密码}
       new_member_password GET /members/password/new(.:format){:行动=>中新:控制器=>中设计/密码}
      edit_member_password GET /members/password/edit(.:format){:行动=>中编辑:控制器=>中设计/密码}
                           PUT /members/password(.:format){:行动=>中更新:控制器=>中设计/密码}
cancel_member_registration GET /members/ca​​ncel(.:format){:行动=>中取消:控制器=>中设计/注册}
       member_registration POST /members(.:format){:行动=>中创造,:控制器=>中设计/注册}
   new_member_registration GET /members/sign_up(.:format){:行动=>中新:控制器=>中设计/注册}
  edit_member_registration GET /members/edit(.:format){:行动=>中编辑:控制器=>中设计/注册}
                           PUT /members(.:format){:行动=>中更新:控制器=>中设计/注册}
                           DELETE /members(.:format){:行动=>中消灭,:控制器=>中设计/注册}
         new_admin_session GET /admins/sign_in(.:format){:行动=>中新:控制器=>中设计/会话}
             admin_session POST /admins/sign_in(.:format){:行动=>中创造,:控制器=>中设计/会话}
     destroy_admin_session DELETE /admins/sign_out(.:format){:行动=>中消灭,:控制器=>中设计/会话}
            ADMIN_PASSWORD POST /admins/password(.:format){:行动=>中创造,:控制器=>中设计/密码}
        new_admin_password GET /admins/password/new(.:format){:行动=>中新:控制器=>中设计/密码}
       edit_admin_password GET /admins/password/edit(.:format){:行动=>中编辑:控制器=>中设计/密码}
                           PUT /admins/password(.:format){:行动=>中更新:控制器=>中设计/密码}
 cancel_admin_registration GET /admins/cancel(.:format){:行动=>中取消:控制器=>中设计/注册}
        admin_registration POST /admins(.:format){:行动=>中创造,:控制器=>中设计/注册}
    new_admin_registration GET /admins/sign_up(.:format){:行动=>中新:控制器=>中设计/注册}
   edit_admin_registration GET /admins/edit(.:format){:行动=>中编辑:控制器=>中设计/注册}
                           PUT /admins(.:format){:行动=>中更新:控制器=>中设计/注册}
                           DELETE /admins(.:format){:行动=>中消灭,:控制器=>中设计/注册}
                     电影GET /films(.:format){:行动=>中指数,:控制器=>中的电影}
                           POST /films(.:format){:行动=>中创造,:控制器=>中的电影}
                  new_film GET /films/new(.:format){:行动=>中新:控制器=>中的电影}
                 edit_film GET /films/:id/edit(.:format){:行动=>中编辑:控制器=>中的电影}
                      电影GET /films/:id(.:format){:行动=>中表演,:控制器=>中的电影}
                           PUT /films/:id(.:format){:行动=>中更新:控制器=>中的电影}
                           DELETE /films/:id(.:format){:行动=>中消灭,:控制器=>中的电影}
                      根/ {:控制器=>中的电影:动作=>中的索引}

的routes.rb

  FilmRepo :: Application.routes.draw做
  devise_for:会员  devise_for:管理员  资源:电影  根:以= GT; 电影#索引
结束

admin.rb(模型)

 类管理< ActiveRecord的::基地
  #包括默认色器件模块。可用其他是:
  #:token_authenticatable,:可加密,:可证实,:可锁定和:omniauthable
  设计:database_authenticatable,:可注册,:timeoutable,
         :可恢复的,:rememberable,:可追踪,:可验证  #设置访问(或保护)属性模型
  attr_accessible:电子邮件,:密码:password_confirmation,:remember_me
结束

member.rb(模型)

 类会员< ActiveRecord的::基地
  #包括默认色器件模块。可用其他是:
  #:token_authenticatable,:可加密,:可证实,:可锁定,:timeoutable和:omniauthable
  设计:database_authenticatable,:可注册,
         :可恢复的,:rememberable,:可追踪,:可验证  #设置访问(或保护)属性模型
  attr_accessible:电子邮件,:密码:password_confirmation,:remember_me
结束

application.html.haml

 
HTML%
    %头
        %标题电影回购
        = stylesheet_link_tag编译/ screen.css':媒体= GT; 屏幕上,投影'
        = stylesheet_link_tag编译/ print.css':媒体= GT; '打印'
        / [如果LT IE 8]
            = stylesheet_link_tag编译/ ie.css':媒体= GT; 屏幕上,投影'
            = csrf_meta_tag
    %body.bp
        #容器
            #user_nav
                 - 如果member_signed_in?
                    签名作为#{} current_member.email。不是你?
                    \\#{的link_to退出,destroy_member_session_path}
                 - 其他
                    =的link_to注册,new_member_registration_path
                    或#{的link_to登录,new_member_session_path}
                 - flash.each做|名,味精|
                    = content_tag:DIV,味精,:ID => 闪_#(名称)
            收益率=


解决方案

我也有类似的问题,但另外的:方法=>:删除没有工作。
我能够通过注释掉devise_for添加一个新的路线为GET请求:用户并添加

  devise_for:用户做
  得到'/用户/ SIGN_OUT'=> 色器件/会话#销毁
结束

Here is my actual error: No route matches [GET] "/members/sign_out" Since most people will use "users" I thought it would be more helpful to have that in the title. At any rate, I am essential unable to logout. I can successfully edit my member profile.

I am using devise 1.4.2 and Rails 3.1.0.rc4. Also, I have generated two separate devise models - one called "members" and the other called "admins". I was able to register and log into both of them (simultaneously) by manually navigating to the correct URL path (i.e., localhost:3000/admins/sign_in/). I created some links within my application.html.haml layout file by following this RailsCast on Devise. I am aware that it only addresses signin/signout links for "members."

If I click on the signout link I get the above error. This occurs if I manually navigate to either signout URL (i.e., localhost:3000/admins/sign_out/).

Can someone tell me why this is happening? Below are the various related files. And of course, I'm a newbie...

rake routes output:

    j(film_repo)$ rake routes
        new_member_session GET    /members/sign_in(.:format)       {:action=>"new", :controller=>"devise/sessions"}
            member_session POST   /members/sign_in(.:format)       {:action=>"create", :controller=>"devise/sessions"}
    destroy_member_session DELETE /members/sign_out(.:format)      {:action=>"destroy", :controller=>"devise/sessions"}
           member_password POST   /members/password(.:format)      {:action=>"create", :controller=>"devise/passwords"}
       new_member_password GET    /members/password/new(.:format)  {:action=>"new", :controller=>"devise/passwords"}
      edit_member_password GET    /members/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
                           PUT    /members/password(.:format)      {:action=>"update", :controller=>"devise/passwords"}
cancel_member_registration GET    /members/cancel(.:format)        {:action=>"cancel", :controller=>"devise/registrations"}
       member_registration POST   /members(.:format)               {:action=>"create", :controller=>"devise/registrations"}
   new_member_registration GET    /members/sign_up(.:format)       {:action=>"new", :controller=>"devise/registrations"}
  edit_member_registration GET    /members/edit(.:format)          {:action=>"edit", :controller=>"devise/registrations"}
                           PUT    /members(.:format)               {:action=>"update", :controller=>"devise/registrations"}
                           DELETE /members(.:format)               {:action=>"destroy", :controller=>"devise/registrations"}
         new_admin_session GET    /admins/sign_in(.:format)        {:action=>"new", :controller=>"devise/sessions"}
             admin_session POST   /admins/sign_in(.:format)        {:action=>"create", :controller=>"devise/sessions"}
     destroy_admin_session DELETE /admins/sign_out(.:format)       {:action=>"destroy", :controller=>"devise/sessions"}
            admin_password POST   /admins/password(.:format)       {:action=>"create", :controller=>"devise/passwords"}
        new_admin_password GET    /admins/password/new(.:format)   {:action=>"new", :controller=>"devise/passwords"}
       edit_admin_password GET    /admins/password/edit(.:format)  {:action=>"edit", :controller=>"devise/passwords"}
                           PUT    /admins/password(.:format)       {:action=>"update", :controller=>"devise/passwords"}
 cancel_admin_registration GET    /admins/cancel(.:format)         {:action=>"cancel", :controller=>"devise/registrations"}
        admin_registration POST   /admins(.:format)                {:action=>"create", :controller=>"devise/registrations"}
    new_admin_registration GET    /admins/sign_up(.:format)        {:action=>"new", :controller=>"devise/registrations"}
   edit_admin_registration GET    /admins/edit(.:format)           {:action=>"edit", :controller=>"devise/registrations"}
                           PUT    /admins(.:format)                {:action=>"update", :controller=>"devise/registrations"}
                           DELETE /admins(.:format)                {:action=>"destroy", :controller=>"devise/registrations"}
                     films GET    /films(.:format)                 {:action=>"index", :controller=>"films"}
                           POST   /films(.:format)                 {:action=>"create", :controller=>"films"}
                  new_film GET    /films/new(.:format)             {:action=>"new", :controller=>"films"}
                 edit_film GET    /films/:id/edit(.:format)        {:action=>"edit", :controller=>"films"}
                      film GET    /films/:id(.:format)             {:action=>"show", :controller=>"films"}
                           PUT    /films/:id(.:format)             {:action=>"update", :controller=>"films"}
                           DELETE /films/:id(.:format)             {:action=>"destroy", :controller=>"films"}
                      root        /                                {:controller=>"films", :action=>"index"}

routes.rb

FilmRepo::Application.routes.draw do
  devise_for :members

  devise_for :admins

  resources :films

  root :to => 'films#index'
end

admin.rb (model)

class Admin < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, and :omniauthable
  devise :database_authenticatable, :registerable, :timeoutable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end

member.rb (model)

class Member < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end

application.html.haml

!!!
%html
    %head
        %title Film Repo
        = stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
        = stylesheet_link_tag 'compiled/print.css', :media => 'print'
        /[if lt IE 8]
            = stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
            = csrf_meta_tag
    %body.bp
        #container
            #user_nav
                - if member_signed_in?
                    Signed in as #{current_member.email}. Not you?
                    \#{link_to "Sign out", destroy_member_session_path}
                - else
                    = link_to "Sign up", new_member_registration_path
                    or #{link_to "sign in", new_member_session_path}
                - flash.each do |name, msg|
                    = content_tag :div, msg, :id => "flash_#{name}"
            = yield

解决方案

I had a similar problem, but addition of the :method=> :delete didn't work. I was able to add a new route for a the get request by commenting out the devise_for :users and adding

devise_for :users do
  get '/users/sign_out' => 'devise/sessions#destroy'
end

这篇关于没有路由匹配[GET] QUOT; /用户/ SIGN_OUT&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆