Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何解决ImageMagickeror无法识别的问题?_Ruby On Rails_Ruby_Ruby On Rails 4_Paperclip - Fatal编程技术网

Ruby on rails 如何解决ImageMagickeror无法识别的问题?

Ruby on rails 如何解决ImageMagickeror无法识别的问题?,ruby-on-rails,ruby,ruby-on-rails-4,paperclip,Ruby On Rails,Ruby,Ruby On Rails 4,Paperclip,单击“创建用户”按钮时,出现以下错误: Avatar Paperclip::Errors::NotIdentifiedByImageMagickError 我的代码片段如下所示: Gemfile source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.7' # Use sqlite3 as the database for

单击“创建用户”按钮时,出现以下错误:

Avatar Paperclip::Errors::NotIdentifiedByImageMagickError
我的代码片段如下所示:

Gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.7'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Paperclip gem for managing file uploads
gem 'paperclip', '~> 3.0'
gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin]
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
views/users/index.html.erb

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Original Avatar</th>
      <th>Thumbnail Avatar</th>
      <th>Resume Filename</th>
    </tr>
  </thead>

  <tbody>
    <% @users.each do |user| %>
      <tr>
        <td><%= user.name %></td>
        <!-- display the avatar in both the original size and the thumbnail size -->
        <td><%= image_tag user.avatar.url %></td>
        <td><%= image_tag user.avatar.url(:thumb) %></td>

        <!-- show the filename for the resume -->
        <td><%= user.resume_file_name %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New User', new_user_path %>
我已经在我的系统上安装了
ImageMagick-6.9.0-Q16
。我正在使用rails-4和ruby-1.9.3


如果能帮我找到解决办法,我将不胜感激。提前感谢。

最有可能的原因是可卡因4的API变化,而回形针还没有跟上。通过将以下行插入您的文件,尝试使用早期版本的可卡因:


gem“cookine”,“=0.3.2”

Hello Dipak,没有its再次给出与添加gem“cookine”,“=0.3.2”后所解释的相同的错误消息在Gemfile中运行命令包更新。解决此错误的任何其他想法。请与我分享。看起来这已经被修复,因为回形针3.3:github.com/thoughtbot/paperclip/issues/1038截至2014年1月2日,回形针3.5.2需要可卡因~>0.5.3Dipak,我已经对您的评论做了一些小的更改。我做了gem“cookine”、“~>0.5.3”并且也进行了捆绑包更新..但是没有什么新的错误是相同的.无论如何,谢谢。。
<h1>New user</h1>

<%= render 'form' %>

<%= link_to 'Back', users_path %>
<%= form_for(@user) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

      <ul>
      <% @user.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br>
    <%= f.text_field :name %>
  </div>
  <!-- Upload your attachments via a simple file_fields in the form -->
  <div class="field">
    <%= f.label :avatar %><br>
    <%= f.file_field :avatar %>
  </div>
  <div class="field">
    <%= f.label :resume %><br>
    <%= f.file_field :resume %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
class UsersController < ApplicationController
 # GET /users
  def index
    @users = User.all
  end

  # GET /users/new
  def new
    @user = User.new
  end

  # POST /users
  def create
    @user = User.new(user_params)

    if @user.save
      redirect_to action: 'index', notice: 'User was successfully created.'
    else
      render action: 'new', alert: 'User could not be created' 
    end
  end

  private

    # Never trust parameters from the scary internet, only allow the white list through.
    def user_params
      params.require(:user).permit(:name, :avatar, :resume)
    end
end
class User < ActiveRecord::Base
#specify that the avatar is a paperclip file attachment
  #specify additional styles that you want to use in views or eslewhere
  has_attached_file :avatar, :styles => {:thumb => "100x100>"}

  #specify that the resume is a paperclip file attachment
  has_attached_file :resume

end
Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true
  Paperclip.options[:command_path] = 'C:\Program Files\ImageMagick-6.9.0-Q16'
  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end