재정의 된 암호 암호 컨트롤러의 오류 메시지는 어떻게 사용자 정의 할 수 있습니까?암호 변경시 오류 메시지 무시 방법
class PasswordsController < Devise::PasswordsController
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if resource.errors.empty?
set_flash_message(:notice, :send_instructions) if is_navigational_format?
respond_with resource, :location => home_path
else
binding.pry
flash[:devise_password_error] = (resource.errors.map do |key, value|
value.capitalize
end).flatten.join('|')
redirect_to home_path and return
end
end
def edit
self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token]
end
end
resource.errors이 방법에 사용할 수 있지만 그러한 Email not found
및 Email can't be blank
같은 기본 메시지가 들어 있습니다. 이 메시지를 사용자 지정해야합니다. 내 사용자 모델에서 :validatable
을 제거하고 사용자 정의 유효성 검사기를 추가하려고 시도했지만이 작업은 Devise :: RegistrationsController에서 파생 된 사용자 정의 등록 컨트롤러에서만 작동하며 사용자 정의 암호 컨트롤러에서는 작동하지 않습니다.
해결책이 있습니까?
당신이이 문제를 해결 했습니까? –
나는 이것이 오래되었다는 것을 알고 있지만 좀 더 일반적이고 깨끗한 접근법을 원한다면 [this answer] (http://stackoverflow.com/a/18578028/1964165)를 확인한다. – akhanubis