2010-12-23 3 views
0

authlogic을 사용하여 인증합니다. 인증 모델로 사용되는 현재 모델은 사용자 모델입니다. 사용자 테이블에 외래 키가 필요하다는 것을 의미하는 "속한"관계를 사용자에게 추가하고 싶습니다. 사용자의 모델에서 외래 키가 car_id라고합니다. 그러나 어떤 이유로, 나는Authlogic 테이블에 레코드 저장

u = User.find(1) 
u.car_id = 1 
u.save! 

을 할 때 나는

ActiveRecord::RecordInvalid: Validation failed: Password can't be blank 

내 생각 엔이이 authlogic 함께 할 수있는 뭔가가 있다는 것입니다 얻을. 사용자 모델의 암호 확인이 없습니다. 이것은 사용자 테이블에 대한 마이그레이션입니다.

def self.up 
    create_table :users do |t| 
     t.string :email 
     t.string :first_name 
     t.string :last_name 
     t.string :crypted_password 
     t.string :password_salt 
     t.string :persistence_token 
     t.string :single_access_token 
     t.string :perishable_token 
     t.integer :login_count,   :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns 
     t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns 
     t.datetime :last_request_at         # optional, see Authlogic::Session::MagicColumns 
     t.datetime :current_login_at         # optional, see Authlogic::Session::MagicColumns 
     t.datetime :last_login_at          # optional, see Authlogic::Session::MagicColumns 
     t.string :current_login_ip         # optional, see Authlogic::Session::MagicColumns 
     t.string :last_login_ip          # optional, see Authlogic::Session::MagicColumns 
     t.timestamps 
    end 
    end 

그리고 나중에 car_id 열을 추가했습니다.

def self.up 
    add_column :users, :user_id, :integer 
    end 

이 유효성 검사를 사용 중지 하시겠습니까?

답변

0

확실히. Per the docs :

acts_as_authentic do |c| 
    c.ignore_blank_passwords = true 
end