2011-03-31 30 views
2

我有一個使用Paperclip的應用程序,我也使用rake db:seed生成一些可用於幫助引入新用戶的演示帳戶。使用rake db:種子上傳文件

這些演示帳戶應包含的部分信息是對配置文件照片和其他可在Amazon S3上託管的文件的訪問。

seeds文件的一個條目的一個示例:

userdemo = User.find_or_create_by_login(:login => "demo", 
    :email => user.email, 
    :user_type => "admin", 
    :password => "demo", 
    :password_confirmation => "demo") 

我如何用個人資料照片一起創建上面的用戶?這包括將文件從我的硬盤上傳到S3並將該文件與此記錄相關聯。謝謝!

+0

可能重複的[在導軌單元測試 - 與模型紙夾(http://stackoverflow.com/questions/1895092/unit-test-在護欄模型與 - 回形針) – 2012-07-17 04:48:04

回答

相關問題