LoginSignup
7
2

More than 5 years have passed since last update.

Railsのmini_magickで、画像のアップロードに失敗する問題

Last updated at Posted at 2018-05-27

エラーも出ずに、アップロードできない、、、

画像ファイルをnewした@image@image.saveとしても、

(0.3ms)  BEGIN
(0.2ms)  ROLLBACK

のようにsaveが取り消される。

ROLLBACKの理由を表示する

@image.saveの前にbinding.pryを記述して、ターミナルを起動させる。
その後手動でsaveし、ROLLBACKされることを確認してからlogger.debug @image.errors.inspectを入力すると、エラーの理由が表示される。

[1] pry(#<ImagesController>)> @image.save
   (0.2ms)  BEGIN
   (0.2ms)  ROLLBACK
=> false

[2] pry(#<ImagesController>)> logger.debug @image.errors.inspect
#<ActiveModel::Errors:0x007ff982cfbda8 @base=#<Image id: nil, name: "", file: nil, created_at: nil, updated_at: nil>, @messages={:file=>["Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: `identify ...省略

つまりエラーメッセージは、Failed to manipulate with MiniMagick, maybe it is not an image?である。

解決策

調べたところ、ImageMagickのバーションが古いのかもしれないとのこと。よって、ターミナルで

brew update && brew upgrade imagemagick

を実行すると、無事にmini_magickが使えるようになった!

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2