我正在從attachment_fu升級到carrierwave,因爲attachment_fu在導軌3中斷了。Rails 3載波測試夾具?
沒有一個測試能夠運行,因爲我們有無效的fixtures,它使用attachment_fu的附件文件的語法。
例如,我們有一個Post模型,它有一個PostAttachment。這裏是長什麼樣的附着後夾具的數據,如:
a_image:
post_id: 1
attachment_file: <%= Rails.root>/test/files/test.png
這是我得到的錯誤:
ActiveRecord::StatementInvalid: PGError: ERROR: column "attachment_file" of relation "post_attachments" does not exist
LINE 1: INSERT INTO "post_attachments" ("post_id", "attachment_file"...
attachment_file
會被attachment_fu接走了,它會照顧所有處理爲模型創建attachment_fu附件。
有沒有辦法在燈具中有圖像附件,但使用CarrierWave呢?
'File.open(Rails.root + 「/test/files/test.png」)'不適用於工作我。 'File.open(Rails.root.join(「test/files/test.png」))''。 – dkobozev
我改變了它。非常感謝。 – e3matheus
在當前版本的carrierwave上,這不適合我。我試過引用/轉義/ ERBing上面的'File.open ...'調用。我也嘗試過使用'Rack :: Test :: UploadedFile.new(Rails.root.join(「test/files/test.png」))',它在作爲參數傳遞時起作用。 – Leo