我在我的網站中使用Devise我創建管理員命名空間並給予管理員創建用戶的功能。
我的路線是爲下導軌:3設計註冊過濾器鏈暫停爲:require_no_authentication呈現或重定向
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點擊:
我的錯誤
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)
我覺得要去色器件註冊控制器,但由於下面的行它會導致設計註冊控制器中的錯誤
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
您確定沒有登錄用戶嗎?嘗試註銷(或清理您的域的Cookie)並查看它是否有效。 – 2012-03-09 12:17:15
是的,我以管理員身份登錄,管理員可以添加用戶,因此添加用戶頁面(註冊)可以打開並且不會重定向到localhost:3000/admin。 – 2012-03-10 07:37:23
正如我所說我認爲問題是prepend_before_filter:require_no_authentication,:only => [:new,:create,:cancel]。我應該在我的助手中使用require_no_authentication方法嗎? – 2012-03-10 07:38:09