我正在从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