rails:3设计注册过滤器链暂停为:require_no_authentication呈现或重定向 [英] rails:3 Devise signup Filter chain halted as :require_no_authentication rendered or redirected
问题描述
我的路线是在
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 => :注册
get/ logout,:to => devise / sessions#destroy,:as => :logout
end
当我点击add_user链接,它有 signup_path
导致以下错误:
我的错误
开始GET / /注册127.0.0.1在Fri Mar 09 12:49:11 +0530 2012
处理由Devise :: RegistrationsController#new作为HTML
用户负载(0.1ms)SELECT`users`。* FROM`users` WHERE`users`.`id` = 35 LIMIT 1
重定向到http:// localhost:3000 / admin
过滤器链暂停作为:require_no_authentication呈现或重定向
完成302发现在3ms(ActiveRecord:0.1ms)
我认为这是去设计注册控制器,但是由于以下一行,它会导致设计注册控制器中的错误。
prepend_before_filter:require_no_authentication, :only => [:new,:create,,cancel]
Devise控制器上面提到的一般行为在一般情况下是有道理的:登录用户无法注册。正如你在只有管理员可以创建用户的情况下,我建议您不要在可注册
模块中使用Devise的控制器,并将自己的控制器与您的自己的规则。您可以根据Devise的控制器编写更改只提及的行。
如果要使用它,请尝试跳过 before_filter
with skip_before_filter
。我不认为这是最好的解决方案。我会写我自己的控制器。
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
when i click on add_user link which has signup_path
causing following error:
My 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 ]
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.
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屋!