2016-10-04 97 views
0

我完全絕望。我一直試圖安裝ImageMagick窗體兩天,我仍然有問題用Paperclip gem i Rails。 我使用MacOS的塞拉利昂和我已經通過的MacPorts安裝ImageMagick的ImageMagick,回形針,macOs塞拉利昂

sudo port install ImageMagick 

我檢查安裝目錄:

which identify 

,並返回選擇/ local/bin目錄/識別

我已經改變使用development.rb:

Paperclip.options[:command_path] = "/opt/local/bin" 

當我已經輸入控制檯

port info ImageMagick 

我有這個

ImageMagick @6.9.5-10 (graphics, devel) 
Variants:    graphviz, lqr, pango, rsvg, universal, wmf, 
[+]x11 

Description:   ImageMagick is a robust collection of tools and 
libraries 
        to create, edit and compose bitmap images in a wide 
        variety of formats. You can crop, resize, rotate, sharpen, 
        color reduce or add effects or text or straight or curved 
        lines to an image or image sequence and save your 
        completed work in the same or differing image format. You 
        can even create images from scratch. Image processing 
        operations are available from the command line as well as 
        through C, Ch, C++, Java, Perl, PHP, Python, Ruby and 
        Tcl/Tk programming interfaces. Over 90 image formats are 
        supported, including GIF, JPEG, JPEG 2000, PNG, PDF, 
        PhotoCD and TIFF. 
Homepage:    http://www.imagemagick.org/ 

Extract Dependencies: xz 
Build Dependencies: autoconf, automake, libtool 
Library Dependencies: bzip2, djvulibre, xz, jbigkit, jpeg, lcms2, 
libpng, tiff, 
        webp, zlib, fftw-3, freetype, fontconfig, 
ghostscript, 
        libiconv, libtool, openjpeg, openexr, expat, libxml2, 
        pkgconfig, xorg-libX11, xorg-libXext, xorg-libXt 
Runtime Dependencies: urw-fonts 
Platforms:   darwin 
License:    Apache-2 
Maintainers:   [email protected] 

當我創建了一個 「處方」 tehre是一個錯誤:

回形針::中的RecipesController#錯誤創建 出現錯誤處理215f68293f2d16f1f79bd2e366a45a9620160928-61978-d794或的縮略圖

我的控制器廁所KS這樣的:

class RecipesController < ApplicationController 
before_action :find_recipe, only: [:show, :edit, :update, :destroy] 
def index 
    @recipe = Recipe.all.order("created_at DESC") 
end 

def new 
    @recipe = Recipe.new 
end 

def show 
end 

def create 
    @recipe = Recipe.new(recipe_params) 
    if @recipe.save 
     redirect_to @recipe, notice: 'Succesfully created new recipe' 
    else 
     render 'new' 
    end 
end 

def edit 
end 

def update 
    if @recipe.update(recipe_params) 
     redirect_to @recipe 
    else 
     render 'edit' 
    end 
end 

def destroy 
    @recipe.destroy 
    redirect_to root_path, notice: "Succesfully deleted" 
end 

private 

def recipe_params 
    params.require(:recipe).permit(:title, :description, :image) 
end 

def find_recipe 
    @recipe = Recipe.find(params[:id]) 
end 
end 

型號:

class Recipe < ApplicationRecord 
has_attached_file :image, styles: { medium: "400x400#>" } 
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/ 
end 

和形式:

= simple_form_for @recipe, html: { multipart: true } do |f| 
- if @recipe.errors.any? 
    #errors 
     %p 
      = @recipe.errors.count 
      Prevented this recipe froms saving 
     %ul 
      - @recipe.errors.full_messages.each do |msg| 
       %li= msg 
.panel-body 
    = f.input :title, input_html: { class: 'form-control' } 
    = f.input :description, input_html: { class: 'form-control' } 
    = f.input :image, input_html: { class: 'form-control' } 

= f.button :submit, class: "btn btn-primary" 

當我創建的配方不選擇它工作正常的圖像,但是當我選擇一個我有錯誤。

我不知道問題在哪裏。我應該更新MagickInfo還是...?

回答

0

這可能是幫助卸載XZ

brew uninstall xz 
0

這說明我多麼愚蠢我。問題出在AdBlock在Chrome中運行。它也阻止了Rails中的圖像。