我開始玩Devise,但認爲我缺乏自由,當我按照Michael Hartl教程直接使用Rails進行身份驗證時。然後,我爲我的Devise模型'客戶'生成了Devise控制器。所以,我可以玩了一下它:生成設計控制器是空的
rails generate devise:controllers clients
雖然結果是空的控制器:
class Clients::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
# def create
# super
# end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
所以我想真正的設計控制器不能在所有訪問,我們剛剛得到的控制器從繼承真正的隱藏Devise控制器?
這個問題可能可以幫助,http://stackoverflow.com/questions/3546289/override-devise-registrations-controller –
是的,我讀了這個線程。雖然我認爲生成Devise模型控制器會帶來實際的設備控制器。但它只是創建空的繼承控制器。總的來說,我發現它處理Devise事件相當困難,儘管它簡化了很多事情,比如電子郵件確認,... – Maxence
是的,我也是這麼想的。現在我喜歡它。快樂的編碼。 –