Rails 一个应用里有两个地方用到 devise,注销后的转向

nancy · 2012年05月08日 · 最后由 stephen 回复于 2013年03月26日 · 4511 次阅读

一个应用现在有 devise_for :users 和 devise_for :admins 注销 users 账户的时候跳转到默认的 root gitHub 上是在 class ApplicationController < ActionController::Base private # Overwriting the sign_out redirect path method def after_sign_out_path_for(resource_or_scope) root_path end end

我需要把 after_sign_out_path_for 放在哪儿?我新建了 user/registrations 和 user/sessions

嗯,想两个 devise 注销时转向不同的路径,不知道怎么弄,现统一转向同一个页面了

def after_sign_out_path_for(resource_or_scope) if resource_name == :administrator new_administrator_session_path else new_user_session_path end end

跟贴问个, devise 这个 gem 是不是要在项目开始时就使用?我原本写好了 user 这个 model,现在想用 devise 做角色管理,执行了 rails g devise user 后就把原本写的 user.rb 给覆盖了。

不会覆盖的,会在里面添加 devise 的内容

sandy_xu 谢谢! 我现在修改密码,路由里是这么定义的 devise_scope :user do match "/signout" => "devise/sessions#destroy" match '/editpass' => "devise/passwords#edit" match '/savepass' => "devise/passwords#update" end 但后台总是报 Started GET "/editpass" for 127.0.0.1 at 2012-05-08 17:17:43 +0800 Processing by Devise::PasswordsController#edit as HTML User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 57 LIMIT 1 Redirected to http://localhost:3000/welcome Filter chain halted as :require_no_authentication rendered or redirected Completed 302 Found in 3ms (ActiveRecord: 0.3ms) Started GET "/welcome" for 127.0.0.1 .......

Filter chain halted as :require_no_authentication rendered or redirected 这个是啥原因引起的?

同求,不知道楼主解决这问题没,我昨天刚好碰到同样的问题

这个问题,估计升级 rails 引起的,Gemfile 文件重新 buid install,注意指定 rails 版本,重启一下,应该可以解决吧

@nancy @py890000 请问这个Filter chain halted as :require_no_authentication rendered or redirected如何解决?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号