모델 유효성 검사 만 사용합니다. 내가 app/users/registrations_controller.rb
에 배치
class Users::RegistrationsController < Devise::RegistrationsController
def create
email = params[:user][:email]
if Admin::Whitelist.find_by_email(email) != nil
super
else
build_resource
set_flash_message :error, "You are not permitted to sign up yet. If you have already payed your registration fee, try again later."
render_with_scope :new
end
end
end
: 나는 당신의 사용자 클래스를 가정하고있어 제안 난 내 자신의 컨트롤러를 생성했던 유증 방법
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable #etc
before_validation :whitelisted
def whitelisted
unless celebrityemail.include? email
errors.add :email, "#{email} is not on our invitation list"
end
end
end
오류의 MSG의 실제 이메일을 표시하려면, 당신은 어떻게이 코드를 변경할 것인가? – Magne
@Magne'errors.add : email, "은 우리의 초대 목록에 없습니다 : # {email}"' –