2016-10-04 100 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中的图像。