4
Failure/Error: post :create, Devise.token_authentication_key => @foo.authentication_token, receipt_image: "foo.png"
 Paperclip::AdapterRegistry::NoHandlerError: No handler found for "foo.png"

rspecコードで画像を渡す方法、curlコマンドで動作する@foo.pngも試しました。

4

1 に答える 1

6

モデル レベルでは、開いているイメージを渡す必要があります。

@foo.image = File.open(Rails.root.join("spec", "fixtures", "sticker.jpg"))
@foo.save!

コントローラー レベルでは、画像へのパスである文字列を渡します。これは絶対パスが最適です。

params[:foo][:image] = Rails.root.join("spec", "fixtures", "sticker.jpg")
post :new, params
于 2013-04-03T13:54:43.763 に答える