我完全绝望了。我已经尝试安装ImageMagick表单两天,我仍然有问题的纸夹创业板,我的Rails。我正在使用macOS塞拉利昂,我已经通过MacPorts安装了ImageMagick
sudo port install ImageMagick我检查了安装目录:
which identify并返回opt/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: ryandesign@macports.org当我创建一个“食谱”时,tehre是一个错误:
215f68293f2d16f1f79bd2e366a45a9620160928-61978-d794or剪纸夹::RecipesController#create中的错误处理缩略图时出错
我的控制器看起来是这样的:
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还是.?
发布于 2016-10-26 19:00:39
卸载xz可能会有所帮助。
brew uninstall xz发布于 2017-05-22 17:54:12
这表明我是多么的愚蠢问题是在Chrome中运行adBlock。它还阻止了Rails中的图像。
https://stackoverflow.com/questions/39856368
复制相似问题