rails:3 设计注册过滤器链停止,因为:require_no_authentication 呈现或重定向 [英] rails:3 Devise signup Filter chain halted as :require_no_authentication rendered or redirected
问题描述
我在我的站点中使用 Devise 我创建了管理员命名空间并提供了由管理员创建用户的功能.
我的路线如下
I am using Devise in my site I create admin namespace and giving functionality of create user by admin.
my routes are as under
devise_for :users,:has_many => :comments, :controllers => {:sessions =>'devise/sessions',:registrations => 'devise/registrations'} do
get "/login", :to => "devise/sessions#new", :as => :login
get "/signup", :to => "devise/registrations#new", :as => :signup
get "/logout", :to => "devise/sessions#destroy", :as => :logout
end
当我单击具有 signup_path
的 add_user 链接时,会导致以下错误:
when i click on add_user link which has signup_path
causing following error:
我的错误
Started GET "/signup" for 127.0.0.1 at Fri Mar 09 12:49:11 +0530 2012
Processing by Devise::RegistrationsController#new as HTML
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 35 LIMIT 1
Redirected to http://localhost:3000/admin
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 3ms (ActiveRecord: 0.1ms)
我认为它会转到设计注册控制器,但由于以下行,它会导致设计注册控制器出错
I think it going to the devise registration controller but due to following line it cause an error in devise registration controller
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
推荐答案
Devise 的 Controller 上提到的那一行在一般情况下是有意义的:登录的用户无法注册.由于您处于只有管理员才能创建用户的情况下,我建议您不要在 Registerable
模块上使用 Devise 的控制器,而是使用自己的规则编写自己的控制器.您可以根据 Devise 的控制器编写它,只更改提到的行.
The mentioned line on Devise's Controller makes sense in general cases: a logged in user can't sign up. As you're on a case where only an admin can create a user, I would suggest that you don't use Devise's controller on Registerable
module and write your own controller with your own rules. You can write it based on Devise's controller changing only the mentioned line.
如果您想使用它,请尝试使用 skip_before_filter
跳过 before_filter
.我不认为这是最好的解决方案.我会写我自己的控制器.
If you want to use it, try skipping the before_filter
with skip_before_filter
. I don't think it is the best solution. and I would write my own controller.
这篇关于rails:3 设计注册过滤器链停止,因为:require_no_authentication 呈现或重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!