質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

2回答

4279閲覧

【rails/paperclip】Paperclip::Errors::NotIdentifiedByImageMagickError

shigenshigen

総合スコア9

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

0クリップ

投稿2014/10/31 01:35

ruby on rails でpaperclipを使って画像upload機能をつけようとしているのですが、
画像upload時に、
Paperclip::Errors::NotIdentifiedByImageMagickError
と出て上手く動作しません。

githubのreadmeや
https://github.com/thoughtbot/paperclip
下記記事などを参考にコードを書いているのですが、何度やっても同じエラーが出てしまいます。
http://ruby-rails.hatenadiary.com/entry/20140716/1405443484

新たにアプリを作成しても、paperclipが標準搭載されたオープンソースのアプリをインストールしてみても画像upload時に同じエラーが出ます。

config/enviroments/deveropment.rb/には、
Paperclip.options[:command_path] = "/usr/local/bin/"
を入れて、
それぞれのファイルは下記のように書いています。

原因の分かる方がいらっしゃればご教示頂ければ幸いです。

何卒よろしくお願い致します。


db/migrate/20141030103816_add_attachment_avatar_to_items.rb

lang

1class AddAttachmentAvatarToItems < ActiveRecord::Migration 2 def self.up 3 change_table :items do |t| 4 t.attachment :avatar 5 end 6 end 7 8 def self.down 9 remove_attachment :items, :avatar 10 end 11end 12 13

app/model/item.rb

lang

1 2class Item < ActiveRecord::Base 3 4has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" 5validates_attachment :avatar, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"] } 6 7end

app/views/items/_form

lang

1 2<%= form_for @item, :url => items_path, :html => { :multipart => true } do |f| %> 3 <% if @item.errors.any? %> 4 <div id="error_explanation"> 5 <h2><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2> 6 7 <ul> 8 <% @item.errors.full_messages.each do |message| %> 9 <li><%= message %></li> 10 <% end %> 11 </ul> 12 </div> 13 <% end %> 14 15 <div class="field"> 16 <%= f.label :name %><br> 17 <%= f.text_field :name %> 18 </div> 19 <div class="field"> 20 <%= f.label :price %><br> 21 <%= f.number_field :price %> 22 </div> 23 24 <%= f.file_field :avatar %> 25 <div class="actions"> 26 27 <%= f.submit %> 28 </div> 29<% end %> 30 31 32 33

app/controllers/items_controller

lang

1class ItemsController < ApplicationController 2 before_action :set_item, only: [:show, :edit, :update, :destroy] 3 4 # GET /items 5 # GET /items.json 6 def index 7 @items = Item.all 8 end 9 10 # GET /items/1 11 # GET /items/1.json 12 def show 13 end 14 15 # GET /items/new 16 def new 17 @item = Item.new 18 end 19 20 def new2 21 @item =Item.new 22 23 end 24 25 # GET /items/1/edit 26 def edit 27 end 28 29 # POST /items 30 # POST /items.json 31 def create 32 @item = Item.create(item_params) 33 34 35 36 respond_to do |format| 37 if @item.save 38 format.html { redirect_to @item, notice: 'Item was successfully created.' } 39 format.json { render :show, status: :created, location: @item } 40 else 41 format.html { render :new } 42 format.json { render json: @item.errors, status: :unprocessable_entity } 43 end 44 end 45 end 46 47 # PATCH/PUT /items/1 48 # PATCH/PUT /items/1.json 49 def update 50 respond_to do |format| 51 if @item.update(item_params) 52 format.html { redirect_to @item, notice: 'Item was successfully updated.' } 53 format.json { render :show, status: :ok, location: @item } 54 else 55 format.html { render :edit } 56 format.json { render json: @item.errors, status: :unprocessable_entity } 57 end 58 end 59 end 60 61 # DELETE /items/1 62 # DELETE /items/1.json 63 def destroy 64 @item.destroy 65 respond_to do |format| 66 format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' } 67 format.json { head :no_content } 68 end 69 end 70 71 private 72 # Use callbacks to share common setup or constraints between actions. 73 def set_item 74 @item = Item.find(params[:id]) 75 end 76 77 # Never trust parameters from the scary internet, only allow the white list through. 78 def item_params 79 params.require(:item).permit(:name, :price, :avatar) #paperclip使う時は:avatarを追加 80 end 81end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

google で "Paperclip::Errors::NotIdentifiedByImageMagickError" を検索した結果から
いくつかを紹介します。

 > Paperclip 利用時に NotIdentifiedByImageMagickError でエラーになる

... X11 をバージョンアップしたらなおりました。 ...

 > PaperClip Error NotIdentifiedByImageMagickError when scaling images

...
brew install ghostscript
...

 > MacでPaperclip::Errors::NotIdentifiedByImageMagickErrorが発生した

...
$ brew update
$ brew upgrade `brew outdated`
$ brew unlink jpeg
$ brew link jpeg
...

 > Paperclip::Errors::NotIdentifiedByImageMagickError #1405

...
brew uninstall imagemagick jpeg libtiff
brew install imagemagick
...

投稿2014/11/01 22:56

katoy

総合スコア22324

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

OSはなんでしょうか?
Macの場合は以下のコマンドで解決している人いるようです。

lang

1brew install libtool --universal 2brew link libtool

また、環境によってはdeveropment.rbの記述は以下の場合もあるようです。

Paperclip.options[:command_path] = "/usr/bin/"

投稿2014/10/31 02:07

sho_cs

総合スコア3541

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shigenshigen

2014/10/31 06:52

早速ご回答頂き誠にありがとうございます。 環境はmacで開発を進めております。 ご教示頂いた方法も両方試してみましたが、動作しませんでした。 他にご存知であればご教示頂ければ幸いに存じます。 何卒よろしくお願い致します。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問