Devise functionality needs to be customized and the the RegistrationsController
is created.
However, the default set-up for the create action is
super do |resource|
end
which in itself is a bit of a black box, as it goes to the superclass. It obvious is wired up for redirection. Thus:
super do |resource|
[...]
if @user.save?
redirect_to some_user_attribute_path
else
redirect_to a_parameter_based_path
end
end
is not possible as it will naturally create a
AbstractController::DoubleRenderError in Users::RegistrationsController#create
Devise wikis only deal with successful actions or all-encompassing approaches.
It is a goal to avoid ApplicationController methods, as this use-case has very specific behaviours for only user creation according success or failure (in practice the return is to the same page, but in the case of the failure, is defined via a params[:company][:id]
value in lieu of @user.company_id
How can this be achieved?
question from:
https://stackoverflow.com/questions/66061571/overriding-devise-registration-controller-for-redirect 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…