데이터베이스를 시드하려고 시도 할 때 사용자 모델의 전자 메일 특성에 대한 유효성 검사 오류가 발생했습니다. 오류 :레일 유효성 검사 오류 전자 메일이 너무 짧아서 전자 메일이 유효하지 않습니다.
Validation failed: Email is too short (minimum is 5 characters), Email is invalid
문제는 내 이메일이 [email protected]
입니다. 나는 다섯자를 가지고있다. 초급 질문에 대한 미안하지만 무슨 일이 일어나고 있는지 모르겠다. 나는 최근 Railscasts를 따라 사용자 암호를 재설정하고 CanCan을 활성화했습니다. CanCan이 아무런 영향을 미치지 않을지 모르겠지만 새로운 기능을 탐색하기 전에 문제없이 데이터베이스를 완전히 시드 할 수있었습니다. 아래 코드 중 일부에 붙여 넣었습니다. 나는 Rails 3.0.5
과 Ruby 1.9.2
을 실행 중입니다.
내 시드 파일에 사용자를 만드는 방법의 예 :이
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :password, :password_confirmation
before_save :encrypt_new_password
before_create { generate_token(:auth_token) }
before_validation :downcase_email
has_one :profile, :dependent => :destroy
accepts_nested_attributes_for :profile
validates :email, :uniqueness => true,
:length => { :within => 5..50 },
:format => { :with => /^[^@][\w.-][email protected][\w.-]+[.][a-z]{2,4}$/i }
validates :password, :confirmation => true,
:length => { :within => 4..20 },
:presence => true,
:if => :password_required?