[英]Edit Devise failed registration path - Rails
我一直在搜索有關如何在注冊失敗后編輯注冊路徑的文檔的高低搜索。
我在我的網站索引頁面上有我的注冊表單。 在注冊失敗時,它會重定向到new_user_registration_path而不是用戶所在的root。 我該如何更新?
我已經能夠通過使用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
當然可以使用類似的選項,這不需要覆蓋設計注冊控制器嗎?
您可以從此處復制設計注冊控制器
你應該可以添加這樣的東西:
if resource.save
#handle this
else
#handle this
redirect_to new_user_registration_path
end
然后在你的路線:
devise_for :users, :controllers => {:registrations => 'registrations'}
如果不重寫控制器,我不知道該怎么做
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.