[英]devise confirmable routing - rails 4
我是鐵桿新手,任何建議和幫助將不勝感激。
我目前正在使用設計確認
當用戶第一次注冊時,他們會得到:
到現在為止還挺好。
我試圖在用戶注冊時將用戶重定向到另一個頁面,但不確定如何 - 任何建議都會非常感激
application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def after_sign_in_path_for(resources)
if userr_signed_in?
dashboard_path
elsif usera_signed_in?
admin_path
else
dashboardj_path
end
end
def after_sign_out_path_for(resources)
new_feedback_path
end
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email) }
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:category_businesstype_id, :firstname, :lastname, :companyname, :email, :password, :category_role_id, :staff, :number, :hear, :city, :category_qualification_id, :language, :category_careerlevel_id, :desiredjob, :category_distance_id, :category_cvpreference_id, :category_joboption_id, :preferedlocation, :category_notice_id, :category_country_id, :category_positiontype_id ) }
end
end
根據您的情況,您希望在特定路徑上注冊后重定向用戶。 為此,您需要覆蓋after_sign_up_path而不是after_sign_in_path。
在應用程序控制器中,您應該有此方法
def after_sign_up_path_for(resource)
after_registration_path // Your path should goes here
end
只有當您嘗試在注冊后立即將用戶實際登錄到系統時,才能使用sign_in路徑。 在這里,您只需重定向用戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.