2010-08-27 35 views
4

我使用Rails 3 rc,Factory Girl和Rspec以及Authlogic。 有什麼辦法或原因,這種情況會發生:我得到一個問題與密碼確認是「太短」Rails 3和Factory Girl僅在屬性通過時才創建用戶

@user = Factory(:user) 

當我創建一個用戶是這樣的。

我factories.rb是

Factory.define :user do |u| 
     u.username "Test User" 
     u.email  "[email protected]" 
     u.password "aoeuaoeu" 
     u.password_confirmation "aoeuaoeu" 
     #u.password_confirmation {|u| u.password} 
    end 

但是,當我創建一個爲我傳遞:密碼:手動password_confirmation, 它工作得很好。

@user = Factory(:user, :password => "aoeuaoeu", 
         :password_confirmation => "aoeuaoeu") 

有沒有人有任何想法可能導致這種情況?

+0

You pro在隱藏password_confirmation字段的地方有一個attr_protected調用。 – 2011-01-18 04:09:35

+0

這不是attr_protected - 工廠女孩使用setter – psyho 2011-01-21 17:19:37

回答

相關問題