我一直在搜索關於如何在註冊失敗後編輯註冊路徑的文檔。編輯設計失敗的註冊路徑 - 導軌
我在我的網站索引頁上有我的註冊表單。在註冊失敗時,它將重定向到用戶所在的new_user_registration_path而不是root用戶。我如何更新這個?
我一直在搜索關於如何在註冊失敗後編輯註冊路徑的文檔。編輯設計失敗的註冊路徑 - 導軌
我在我的網站索引頁上有我的註冊表單。在註冊失敗時,它將重定向到用戶所在的new_user_registration_path而不是root用戶。我如何更新這個?
您可以將色器件註冊控制器從here
複製你應該能夠增加一些這樣的:
if resource.save
#handle this
else
#handle this
redirect_to new_user_registration_path
end
然後在您的路線:
devise_for :users, :controllers => {:registrations => 'registrations'}
我不是當然如何做到這一點,而不會超越控制器
我已經能夠做到這一點的註冊表單使用customfailure應用
class CustomFailure < Devise::FailureApp
def redirect_url
if warden_options[:scope] == :user
new_user_registration_path
else
new_user_registration_path
end
end
def respond
if http_auth?
http_auth
else
redirect
end
end
def redirect
store_location!
flash[:alert] = i18n_message unless flash[:notice]
redirect_to '/'
end
end
當然類似的選項是可能的,這並不需要重寫色器件註冊控制器?
但你失去了devise_error_messages中的錯誤信息 - 有什麼辦法來保存這些?似乎應該很容易考慮到操作系統甚至不想重定向 - 他們希望用戶留在當前頁面上! – jackocnr 2012-11-02 15:47:53