我已经在我的rails应用程序中覆盖了Devise的密码控制器。但它没有正常工作。点击“重置密码链接”,有时会调用密码#create进入gem或者有时会进入被覆盖的控制器。我的控制器看起来像:
class Users::PasswordsController < Devise::PasswordsController
layout 'lunchbox/lunchbox', only: [:lunchbox_forgot, :lunchbox_recover]
def create
self.resource = resource_class.send_reset_password_instructions(resource_params)
if successfully_sent?(resource)
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
flash[:error] = "Email not found"
redirect_path = params[:user][:lunchbox] ? lunchbox_forgot_password_path : new_user_password_path
redirect_to redirect_path
end
end
end